near / borsh-rs

Rust implementation of Binary Object Representation Serializer for Hashing
https://borsh.io/
Apache License 2.0
299 stars 65 forks source link

chore!: don’t unnecessarily add types recursively in `borsh::BorshSchema` derives #251

Closed mina86 closed 10 months ago

mina86 commented 10 months ago

Firstly, change add_definition function to return whether the definition has been added or it already existed in the map. This avoids double map lookup in places which conditionally add component definitions.

Secondly, use the check consistently in all places so that component definitions aren’t processed unnecessarily.


NOTE: formally, this is a breaking change, as borsh-derive with this change of version, say, 1.2.0 won't be compatible with borsh 1.1.0. Hopefully, tilde version requirement adresses this problem.