-
Notifications
You must be signed in to change notification settings - Fork 316
Closed
Description
We currently iterate over the map on drop:
Lines 1194 to 1195 in efbd036
if mem::needs_drop::<T>() { | |
for item in self.iter() { |
And the iterator iterates over all the buckets, even if it knows there are no more items (RawIter::items == 0
):
Lines 1401 to 1402 in efbd036
fn next(&mut self) -> Option<Bucket<T>> { | |
if let Some(b) = self.iter.next() { |
This means that code like this will unnecessarily take fairly long:
let map: HashMap<String, String> = HashMap::with_capacity(1024 * 1024);
drop(map);
The above is a little contrived, but the same occurs if the caller calls drain
or clear
, and then drops the map. Not sure if this is something we want to optimize for, but the fix is fairly straightforward.
Metadata
Metadata
Assignees
Labels
No labels