Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent capacity handling in HeaderMap::with_capacity #353

Closed
Qwaz opened this issue Nov 16, 2019 · 3 comments
Closed

Inconsistent capacity handling in HeaderMap::with_capacity #353

Qwaz opened this issue Nov 16, 2019 · 3 comments
Labels
A-headers Area: HTTP headers E-easy Effort: easy. Start here :D S-performance Severity: performance. Make existing functionality go faster.

Comments

@Qwaz
Copy link

Qwaz commented Nov 16, 2019

entries: Vec::with_capacity(raw_cap),

self.entries = Vec::with_capacity(usable_capacity(cap));

self.entries = Vec::with_capacity(usable_capacity(new_raw_cap));

HeaderMap::with_capacity reserves the entry vector with Vec::with_capacity(raw_cap), while other functions reserves the same entry with Vec::with_capacity(usable_capacity(raw_cap)).

@hawkw
Copy link
Contributor

hawkw commented Nov 18, 2019

@Qwaz could you provide some additional details on why this is incorrect? Thanks!

@Qwaz
Copy link
Author

Qwaz commented Nov 19, 2019

@hawkw This is not an incorrect code in terms of correctness, but we can improve the consistency of the code and save a bit of memory by changing HeaderMap::with_capacity to use Vec::with_capacity(usable_capacity(raw_cap)) instead of Vec::with_capacity(raw_cap).

@hawkw
Copy link
Contributor

hawkw commented Nov 19, 2019

@Qwaz ah, okay, I misunderstood — I thought that since this was linked in the "Audit http" issue on safety-dance, this was part of the security audit. Thanks for clearing that up.

@seanmonstar seanmonstar added A-headers Area: HTTP headers E-easy Effort: easy. Start here :D S-performance Severity: performance. Make existing functionality go faster. labels Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-headers Area: HTTP headers E-easy Effort: easy. Start here :D S-performance Severity: performance. Make existing functionality go faster.
Projects
None yet
Development

No branches or pull requests

3 participants