Skip to content

Commit b95da8a

Browse files
committed
fixup singleton guards
1 parent cf2995a commit b95da8a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/raw/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,10 @@ impl<T> RawTable<T> {
649649
#[inline]
650650
pub fn clear_no_drop(&mut self) {
651651
unsafe {
652-
if !self.is_empty_singleton() {
653-
self.ctrl(0).write_bytes(EMPTY, self.num_ctrl_bytes());
652+
if self.is_empty_singleton() {
653+
return;
654654
}
655-
655+
self.ctrl(0).write_bytes(EMPTY, self.num_ctrl_bytes());
656656
let header = self.header_mut();
657657
header.items = 0;
658658
header.growth_left = bucket_mask_to_capacity(header.bucket_mask);
@@ -869,6 +869,11 @@ impl<T> RawTable<T> {
869869

870870
// Allocate and initialize the new table.
871871
let mut new_table = Self::try_with_capacity(capacity, fallability)?;
872+
if new_table.is_empty_singleton() {
873+
mem::swap(self, &mut new_table);
874+
return Ok(());
875+
}
876+
872877
let new_header = new_table.header_mut();
873878
new_header.growth_left -= self.items();
874879
new_header.items = self.items();

0 commit comments

Comments
 (0)