diff --git a/src/raw/mod.rs b/src/raw/mod.rs index dbe4640e3..449cf8411 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -758,12 +758,7 @@ impl RawTable { // size. If both the new and old position fall within the // same unaligned group, then there is no benefit in moving // it and we can just continue to the next item. - - let probe_seq_pos = guard.probe_seq(hash).pos; - let probe_index = |pos: usize| { - (pos.wrapping_sub(probe_seq_pos) & guard.bucket_mask) / Group::WIDTH - }; - if likely(probe_index(i) == probe_index(new_i)) { + if likely(guard.is_in_same_group(i, new_i, hash)) { guard.set_ctrl_h2(i, hash); continue 'outer; } @@ -1286,6 +1281,14 @@ impl RawTableInner { self.items += 1; } + #[inline] + fn is_in_same_group(&self, i: usize, new_i: usize, hash: u64) -> bool { + let probe_seq_pos = self.probe_seq(hash).pos; + let probe_index = + |pos: usize| (pos.wrapping_sub(probe_seq_pos) & self.bucket_mask) / Group::WIDTH; + probe_index(i) == probe_index(new_i) + } + /// Sets a control byte to the hash, and possibly also the replicated control byte at /// the end of the array. #[inline]