Share Ancestors API get with contains_key (#27161)
consolidate similar fns
This commit is contained in:
parent
47ca68e51f
commit
dbd2423e9f
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue