You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our implementation of the function that encodes the Document and Array as bytes, we need to allocate a Vec and encode the elements in it to calculate the length. This causes excess memory allocation.
Encoding and decoding of embedded objects and arrays, in principle, work very slowly.
A flat document is processed on the order of ~ 0.002 seconds, while its counterpart with nesting is ~ 0.030 seconds
In our implementation of the function that encodes the Document and Array as bytes, we need to allocate a Vec and encode the elements in it to calculate the length. This causes excess memory allocation.
bson-rust/src/encoder/mod.rs
Lines 96 to 117 in aa4fe08
I looked at RawBson idea, but RawBson is immutable, and we often need to change documents, so it's not particularly useful in practice.
That's why I recommend whether you can maintain a length message when you're building a Document and an Array, just like that:
This allows you to use this length directly when encode, without having to encode to vec first.
The text was updated successfully, but these errors were encountered: