Skip to content

Commit 0ec09ce

Browse files
author
Markus Westerlind
committed
Factor out part of rehash_in_place
1 parent 7e8437f commit 0ec09ce

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/raw/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,7 @@ impl<T, A: Allocator + Clone> RawTable<T, A> {
758758
// size. If both the new and old position fall within the
759759
// same unaligned group, then there is no benefit in moving
760760
// it and we can just continue to the next item.
761-
762-
let probe_seq_pos = guard.probe_seq(hash).pos;
763-
let probe_index = |pos: usize| {
764-
(pos.wrapping_sub(probe_seq_pos) & guard.bucket_mask) / Group::WIDTH
765-
};
766-
if likely(probe_index(i) == probe_index(new_i)) {
761+
if likely(guard.is_in_same_group(i, new_i, hash)) {
767762
guard.set_ctrl_h2(i, hash);
768763
continue 'outer;
769764
}
@@ -1286,6 +1281,14 @@ impl<A: Allocator + Clone> RawTableInner<A> {
12861281
self.items += 1;
12871282
}
12881283

1284+
#[inline]
1285+
fn is_in_same_group(&self, i: usize, new_i: usize, hash: u64) -> bool {
1286+
let probe_seq_pos = self.probe_seq(hash).pos;
1287+
let probe_index =
1288+
|pos: usize| (pos.wrapping_sub(probe_seq_pos) & self.bucket_mask) / Group::WIDTH;
1289+
probe_index(i) == probe_index(new_i)
1290+
}
1291+
12891292
/// Sets a control byte to the hash, and possibly also the replicated control byte at
12901293
/// the end of the array.
12911294
#[inline]

0 commit comments

Comments
 (0)