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

View File

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