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> {
|
impl<'a, T: IsCached> AccountsIndexIterator<'a, T> {
|
||||||
fn range<'b, R>(
|
fn range<R>(
|
||||||
map: &'b AccountMapsReadLock<'b, T>,
|
map: &AccountMapsReadLock<T>,
|
||||||
range: R,
|
range: R,
|
||||||
collect_all_unsorted: bool,
|
collect_all_unsorted: bool,
|
||||||
) -> Vec<(&'b Pubkey, &'b AccountMapEntry<T>)>
|
) -> Vec<(Pubkey, AccountMapEntry<T>)>
|
||||||
where
|
where
|
||||||
R: RangeBounds<Pubkey>,
|
R: RangeBounds<Pubkey>,
|
||||||
{
|
{
|
||||||
let mut result = Vec::with_capacity(map.len());
|
let mut result = Vec::with_capacity(map.len());
|
||||||
for (k, v) in map.iter() {
|
for (k, v) in map.iter() {
|
||||||
if range.contains(k) {
|
if range.contains(k) {
|
||||||
result.push((k, v));
|
result.push((*k, v.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !collect_all_unsorted {
|
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
|
result
|
||||||
}
|
}
|
||||||
@ -735,7 +735,7 @@ impl<'a, T: IsCached> Iterator for AccountsIndexIterator<'a, T> {
|
|||||||
if chunk.len() >= ITER_BATCH_SIZE && !self.collect_all_unsorted {
|
if chunk.len() >= ITER_BATCH_SIZE && !self.collect_all_unsorted {
|
||||||
break 'outer;
|
break 'outer;
|
||||||
}
|
}
|
||||||
let item = (*pubkey, account_map_entry.clone());
|
let item = (pubkey, account_map_entry);
|
||||||
chunk.push(item);
|
chunk.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user