Skip to content

Commit 553da4c

Browse files
committed
Replace insert_potential with mark_inserted
1 parent f0587e6 commit 553da4c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/map.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,10 +1272,13 @@ where
12721272
unsafe {
12731273
let (index, found) = self.table.find_potential(hash, equivalent_key(&k));
12741274

1275+
let bucket = self.table.bucket(index);
1276+
12751277
if found {
1276-
Some(mem::replace(&mut self.table.bucket(index).as_mut().1, v))
1278+
Some(mem::replace(&mut bucket.as_mut().1, v))
12771279
} else {
1278-
self.table.insert_potential(hash, (k, v), index);
1280+
self.table.mark_inserted(index, hash);
1281+
bucket.write((k, v));
12791282
None
12801283
}
12811284
}

src/raw/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -927,14 +927,11 @@ impl<T, A: Allocator + Clone> RawTable<T, A> {
927927
})
928928
}
929929

930-
/// Inserts an element in the table at a potential slot as returned by `find_potential`.
930+
/// Marks an element in the table as inserted.
931931
#[inline]
932-
pub unsafe fn insert_potential(&mut self, hash: u64, value: T, index: usize) -> Bucket<T> {
932+
pub unsafe fn mark_inserted(&mut self, index: usize, hash: u64) {
933933
let old_ctrl = *self.table.ctrl(index);
934934
self.table.record_item_insert_at(index, old_ctrl, hash);
935-
let bucket = self.table.bucket(index);
936-
bucket.write(value);
937-
bucket
938935
}
939936

940937
/// Searches for an element in the table.

0 commit comments

Comments
 (0)