Skip to content

Commit

Permalink
Share Ancestors API get with contains_key (#27161)
Browse files Browse the repository at this point in the history
consolidate similar fns
  • Loading branch information
HaoranYi authored Aug 16, 2022
1 parent 47ca68e commit dbd2423
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions runtime/src/ancestors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ impl Ancestors {
self.ancestors.get_all()
}

pub fn get(&self, slot: &Slot) -> bool {
self.ancestors.contains(slot)
}

pub fn remove(&mut self, slot: &Slot) {
self.ancestors.remove(slot);
}
Expand Down Expand Up @@ -182,10 +178,10 @@ pub mod tests {
let key = item.0;
min = std::cmp::min(min, *key);
max = std::cmp::max(max, *key);
assert!(ancestors.get(key));
assert!(ancestors.contains_key(key));
}
for slot in min - 1..max + 2 {
assert_eq!(ancestors.get(&slot), hashset.contains(&slot));
assert_eq!(ancestors.contains_key(&slot), hashset.contains(&slot));
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/src/status_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<T: Serialize + Clone> StatusCache<T> {
if let Some(stored_forks) = keymap.get(key_slice) {
let res = stored_forks
.iter()
.find(|(f, _)| ancestors.get(f) || self.roots.get(f).is_some())
.find(|(f, _)| ancestors.contains_key(f) || self.roots.get(f).is_some())
.cloned();
if res.is_some() {
return res;
Expand Down

0 comments on commit dbd2423

Please sign in to comment.