From 9899cd359a7f1afa9d8e8d992dd81877b5f84a3a Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Fri, 10 Sep 2021 17:52:49 -0500 Subject: [PATCH] accounts index iterator uses copy of pubkey and account map entry (#19767) --- runtime/src/accounts_index.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index aaea27f045..af4142d070 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -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( + map: &AccountMapsReadLock, range: R, collect_all_unsorted: bool, - ) -> Vec<(&'b Pubkey, &'b AccountMapEntry)> + ) -> Vec<(Pubkey, AccountMapEntry)> where R: RangeBounds, { 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); } }