diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 2a1f2e14f..b4896fa95 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -3854,8 +3854,11 @@ impl AccountsDb { } = self.get_unique_accounts_from_storages(old_storages.iter()); // sort by pubkey to keep account index lookups close - let mut stored_accounts = stored_accounts.into_iter().collect::>(); - stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0)); + let stored_accounts = { + let mut stored_accounts = stored_accounts.into_iter().collect::>(); + stored_accounts.sort_unstable_by(|a, b| a.0.cmp(&b.0)); + stored_accounts + }; let mut index_read_elapsed = Measure::start("index_read_elapsed"); let alive_total_collect = AtomicUsize::new(0); @@ -3895,7 +3898,6 @@ impl AccountsDb { let alive_total = alive_total_collect.load(Ordering::Relaxed); index_read_elapsed.stop(); let aligned_total: u64 = Self::page_align(alive_total as u64); - // we could sort these // could follow what shrink does more closely if stored_accounts.is_empty() { continue; // skipping slot with no useful accounts to write