Open jplatte opened 2 years ago
I don't recall that it's intentional. What does std
do with HashMap
? Are you supposed to call reserve
first, as a user? Or does it do it automatically? Whichever it does, we should follow suit.
hashbrown
does reserve up-front, though not as much as Vec
because some items may be duplicate and not need extra capacity: https://docs.rs/hashbrown/0.11.2/src/hashbrown/map.rs.html#3392-3407
This leads me to a question actually, does HeaderMap
's reserve
reserve space for <amount>
header names or <amount>
header values? The docs don't say so explicitly, though I would assume the former without thinking much about it since the naive implementation of a multimap would basically be HashMap<K, Vec<V>>
.
Is it intentional that the
Extend
implementations forHeaderMap
don't call.reserve
before starting iteration and insertion?