Skip to content
This repository was archived by the owner on Dec 17, 2020. It is now read-only.

Conversation

@baumanj
Copy link
Contributor

@baumanj baumanj commented Feb 27, 2020

Also, check for overflowing the capacity on try_reserve and add tests.
Previously, the argument (named `new_cap`) was unconditionally added to the
existing capacity and the storage was reallocated. This seems to be
inconsistent with existing usage (and the Vec::reserve interface), which
call reserve with the number of additional elements which are about to be
added to the collection, presumably to avoid multiple allocations.

This changes the name of the argument to `additional` and changes the logic
to allocate space for that many additional insertions, considering the
current capacity, and not allocating unnecessarily.

Also, add some additional tests and remove the superfluous `_test` suffix
since test functions are already tagged with `#[test]` attributes.
Copy link
Collaborator

@kinetiknz kinetiknz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find in try_reserve! This doesn't change behaviour since we always passed an empty Vec from mp4parse-rust, but it's good to fix anyway.

Other changes look good to merge, but I'd prefer to implement try_read_to_end inside mp4parse-rust, since it's just building on try_reserve from this crate.

@baumanj
Copy link
Contributor Author

baumanj commented Feb 28, 2020

I'll implement your feedback and upload a new revision. Though I'm going to go through the rest of your feedback on mozilla/mp4parse-rust#193 first in case I need to make any additional changes to this crate.

Also, add try_reserve_idempotent test to check against the specific regression
in try_reserve.
@baumanj
Copy link
Contributor Author

baumanj commented Feb 28, 2020

Changes on this side are done; ready for re-review

@kinetiknz kinetiknz merged commit d460495 into mozilla:master Feb 29, 2020
@kinetiknz
Copy link
Collaborator

Thanks!

@baumanj baumanj deleted the avif branch February 29, 2020 03:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants