range takes a ref (#20140)

This commit is contained in:
Jeff Washington (jwash) 2021-09-23 13:57:56 -05:00 committed by GitHub
parent 093dd68214
commit 254d9c8903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -68,7 +68,7 @@ impl<T: Clone + Copy> Bucket<T> {
rv
}
pub fn items_in_range<R>(&self, range: Option<&R>) -> Vec<BucketItem<T>>
pub fn items_in_range<R>(&self, range: &Option<&R>) -> Vec<BucketItem<T>>
where
R: RangeBounds<Pubkey>,
{

View File

@ -122,7 +122,7 @@ 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>) -> Vec<BucketItem<T>>
pub fn items_in_range<R>(&self, ix: usize, range: &Option<&R>) -> Vec<BucketItem<T>>
where
R: RangeBounds<Pubkey>,
{
@ -435,7 +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>>),
&mut map.items_in_range(bin, &None::<&std::ops::RangeInclusive<Pubkey>>),
);
}
r

View File

@ -99,7 +99,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
Self::update_stat(&self.stats().keys, 1);
// easiest implementation is to load evrything from disk into cache and return the keys
self.start_stop_flush(true);
self.put_range_in_cache(None::<&RangeInclusive<Pubkey>>);
self.put_range_in_cache(&None::<&RangeInclusive<Pubkey>>);
let keys = self.map().read().unwrap().keys().cloned().collect();
self.start_stop_flush(false);
keys
@ -519,7 +519,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
if start_holding {
// put everything in the cache and it will be held there
self.put_range_in_cache(Some(range));
self.put_range_in_cache(&Some(range));
}
// do this AFTER items have been put in cache - that way anyone who finds this range can know that the items are already in the cache
self.just_set_hold_range_in_memory(range, start_holding);
@ -527,7 +527,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
self.start_stop_flush(false);
}
fn put_range_in_cache<R>(&self, range: Option<&R>)
fn put_range_in_cache<R>(&self, range: &Option<&R>)
where
R: RangeBounds<Pubkey>,
{