Skip to content

Commit

Permalink
label probing loops
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Jul 4, 2024
1 parent 96adb8c commit b8dcfb7
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ where
let (mut probe, limit) = Probe::start(h1, self.table.len);

// Probe until we reach the limit.
while probe.len <= limit {
'probe: while probe.len <= limit {
// Load the entry metadata first for cheap searches.
let meta = unsafe { self.table.meta(probe.i) }.load(Ordering::Acquire);

Expand All @@ -465,7 +465,7 @@ where
// Otherwise, continue probing.
InsertStatus::Found(EntryStatus::Null) => {
probe.next();
continue;
continue 'probe;
}
}
}
Expand All @@ -478,7 +478,7 @@ where
// The entry was deleted, keep probing.
if Entry::is_tombstone(found) {
probe.next();
continue;
continue 'probe;
}

// If the key matches, we might be able to update the value.
Expand All @@ -487,19 +487,19 @@ where
// Otherwise, continue probing.
else {
probe.next();
continue;
continue 'probe;
};

// Check for a full match.
fence(Ordering::Acquire);
if unsafe { (*entry.ptr).key != new_ref.key } {
probe.next();
continue;
continue 'probe;
}

// The entry is being copied to the new table.
if entry.tag() & Entry::COPYING != 0 {
break;
break 'probe;
}

// Return an error for calls to `try_insert`.
Expand All @@ -519,7 +519,7 @@ where
}

// The entry is being copied.
UpdateStatus::Found(EntryStatus::Copied(_)) => break,
UpdateStatus::Found(EntryStatus::Copied(_)) => break 'probe,

// The entry was deleted before we could update it, continue probing.
UpdateStatus::Found(EntryStatus::Null) => {}
Expand All @@ -528,9 +528,6 @@ where
UpdateStatus::Found(EntryStatus::Value(found)) => entry = found,
}
}

// Continue probing.
probe.next();
}

// If went over the probe limit or found a copied entry, trigger a resize.
Expand Down Expand Up @@ -622,7 +619,7 @@ where
// Check for a potential match.
if meta != h2 {
probe.next();
continue;
continue 'probe;
}

// Load the full entry.
Expand All @@ -632,14 +629,14 @@ where
// The entry was deleted, keep probing.
if Entry::is_tombstone(entry) {
probe.next();
continue;
continue 'probe;
}

// Check for a full match.
fence(Ordering::Acquire);
if unsafe { (*entry.ptr).key != new_ref.key } {
probe.next();
continue;
continue 'probe;
}

// The entry is being copied to the new table, we have to complete the copy before
Expand Down Expand Up @@ -790,7 +787,7 @@ where
// Check for a potential match.
if meta != h2 {
probe.next();
continue;
continue 'probe;
}

// Load the full entry.
Expand All @@ -800,14 +797,14 @@ where
// The entry was deleted, keep probing.
if Entry::is_tombstone(entry) {
probe.next();
continue;
continue 'probe;
}

// Check for a full match.
fence(Ordering::Acquire);
if unsafe { (*entry.ptr).key.borrow() != key } {
probe.next();
continue;
continue 'probe;
}

// The entry is being copied to the new table, we have to complete the copy before
Expand Down Expand Up @@ -1098,7 +1095,7 @@ where
// Safety: We just removed the old value from this table.
self.defer_retire(entry, guard);

break;
continue 'probe;
},

// Lost to a concurrent update, retry.
Expand Down

0 comments on commit b8dcfb7

Please sign in to comment.