reduce locking on get_rooted_entries (#16304)

This commit is contained in:
Jeff Washington (jwash) 2021-04-05 11:26:53 -05:00 committed by GitHub
parent b242f82696
commit 7a997759fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -685,9 +685,11 @@ impl<T: 'static + Clone + IsCached + ZeroLamport> AccountsIndex<T> {
}
pub fn get_rooted_entries(&self, slice: SlotSlice<T>, max: Option<Slot>) -> SlotList<T> {
let max = max.unwrap_or(Slot::MAX);
let lock = &self.roots_tracker.read().unwrap().roots;
slice
.iter()
.filter(|(slot, _)| self.is_root(*slot) && max.map_or(true, |max| *slot <= max))
.filter(|(slot, _)| *slot <= max && lock.contains(slot))
.cloned()
.collect()
}