accounts index iterator uses copy of pubkey and account map entry (#19767)
This commit is contained in:
committed by
GitHub
parent
11b10439b4
commit
9899cd359a
@ -630,22 +630,22 @@ pub struct AccountsIndexIterator<'a, T: IsCached> {
|
||||
}
|
||||
|
||||
impl<'a, T: IsCached> AccountsIndexIterator<'a, T> {
|
||||
fn range<'b, R>(
|
||||
map: &'b AccountMapsReadLock<'b, T>,
|
||||
fn range<R>(
|
||||
map: &AccountMapsReadLock<T>,
|
||||
range: R,
|
||||
collect_all_unsorted: bool,
|
||||
) -> Vec<(&'b Pubkey, &'b AccountMapEntry<T>)>
|
||||
) -> Vec<(Pubkey, AccountMapEntry<T>)>
|
||||
where
|
||||
R: RangeBounds<Pubkey>,
|
||||
{
|
||||
let mut result = Vec::with_capacity(map.len());
|
||||
for (k, v) in map.iter() {
|
||||
if range.contains(k) {
|
||||
result.push((k, v));
|
||||
result.push((*k, v.clone()));
|
||||
}
|
||||
}
|
||||
if !collect_all_unsorted {
|
||||
result.sort_unstable_by(|a, b| a.0.cmp(b.0));
|
||||
result.sort_unstable_by(|a, b| a.0.cmp(&b.0));
|
||||
}
|
||||
result
|
||||
}
|
||||
@ -735,7 +735,7 @@ impl<'a, T: IsCached> Iterator for AccountsIndexIterator<'a, T> {
|
||||
if chunk.len() >= ITER_BATCH_SIZE && !self.collect_all_unsorted {
|
||||
break 'outer;
|
||||
}
|
||||
let item = (*pubkey, account_map_entry.clone());
|
||||
let item = (pubkey, account_map_entry);
|
||||
chunk.push(item);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user