bucketmap items_in_range does not return Option (#20036)

This commit is contained in:
Jeff Washington (jwash) 2021-09-20 12:18:12 -05:00 committed by GitHub
parent 6926d59d39
commit 4716cd518d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -122,17 +122,16 @@ impl<T: Clone + Copy + Debug> BucketMap<T> {
}
/// Get the items for bucket `ix` in `range`
pub fn items_in_range<R>(&self, ix: usize, range: Option<&R>) -> Option<Vec<BucketItem<T>>>
pub fn items_in_range<R>(&self, ix: usize, range: Option<&R>) -> Vec<BucketItem<T>>
where
R: RangeBounds<Pubkey>,
{
Some(
self.buckets[ix]
.read()
.unwrap()
.as_ref()?
.items_in_range(range),
)
self.buckets[ix]
.read()
.unwrap()
.as_ref()
.map(|bucket| bucket.items_in_range(range))
.unwrap_or_default()
}
/// Get the Pubkeys for bucket `ix`
@ -436,9 +435,7 @@ mod tests {
let mut r = vec![];
for bin in 0..map.num_buckets() {
r.append(
&mut map
.items_in_range(bin, None::<&std::ops::RangeInclusive<Pubkey>>)
.unwrap_or_default(),
&mut map.items_in_range(bin, None::<&std::ops::RangeInclusive<Pubkey>>),
);
}
r