Do not copy data before dropping
This commit is contained in:
parent
d1218a02e0
commit
9de877f9e0
|
@ -312,8 +312,8 @@ impl<T> Drop for Bounded<T> {
|
|||
// Drop the value in the slot.
|
||||
let slot = &self.buffer[index];
|
||||
unsafe {
|
||||
let value = slot.value.get().read().assume_init();
|
||||
drop(value);
|
||||
let value = &mut *slot.value.get();
|
||||
value.as_mut_ptr().drop_in_place();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,10 @@ impl<T> Drop for Single<T> {
|
|||
fn drop(&mut self) {
|
||||
// Drop the value in the slot.
|
||||
if *self.state.get_mut() & PUSHED != 0 {
|
||||
let value = unsafe { self.slot.get().read().assume_init() };
|
||||
drop(value);
|
||||
unsafe {
|
||||
let value = &mut *self.slot.get();
|
||||
value.as_mut_ptr().drop_in_place();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -387,8 +387,8 @@ impl<T> Drop for Unbounded<T> {
|
|||
if offset < BLOCK_CAP {
|
||||
// Drop the value in the slot.
|
||||
let slot = (*block).slots.get_unchecked(offset);
|
||||
let value = slot.value.get().read().assume_init();
|
||||
drop(value);
|
||||
let value = &mut *slot.value.get();
|
||||
value.as_mut_ptr().drop_in_place();
|
||||
} else {
|
||||
// Deallocate the block and move to the next one.
|
||||
let next = *(*block).next.get_mut();
|
||||
|
|
Loading…
Reference in New Issue