-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve calculation for
SerializedValues::with_capacity
It seems that currently the argument provided to this function is being treated as the _number_ of items that we expect to serialize. Normally that would make sense because the argument is passed along to `Vec::with_capacity` which provisions space for the inner `serialized_values` field. However, that field is a `Vec<u8>` so really the argument corresponds to the total _size_ of the serialized values in bytes. This commit tries to be smarter about reserving space by taking into account the actual size in memory of the values to be serialized. It's not perfect (e.g., `String`s will always reserve the same amount of space, regardless of how long their actual contents are) but hopefully it will still result in fewer re-allocations.
- Loading branch information
Showing
1 changed file
with
25 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters