Skip to content

Commit

Permalink
refactor(collections/blazemap/drain): don't drop if it's unneeded
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsonin committed Oct 16, 2023
1 parent 80ac1dd commit 88718e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/collections/blazemap/iter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::{Debug, Formatter};
use std::marker::PhantomData;
use std::mem::needs_drop;
use std::panic::{RefUnwindSafe, UnwindSafe};

use crate::collections::blazemap::BlazeMap;
Expand Down Expand Up @@ -481,6 +482,9 @@ impl<'a, K, V> Drop for Drain<'a, K, V>
{
#[inline]
fn drop(&mut self) {
if !needs_drop::<V>() {
return;
}
let iter = &mut self.inner;
while iter.len != 0 {
let value = unsafe { &mut *iter.inner.add(iter.current_position) };
Expand Down

0 comments on commit 88718e1

Please sign in to comment.