eliminate unnecessary copies in accounts index generation (#18466)

This commit is contained in:
Jeff Washington (jwash) 2021-07-07 15:36:05 -05:00 committed by GitHub
parent 49c4e54b28
commit eca0ceb04c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 15 deletions

View File

@ -5982,21 +5982,22 @@ impl AccountsDb {
} }
let mut stored_sizes_and_counts = HashMap::new(); let mut stored_sizes_and_counts = HashMap::new();
for account_entry in self self.accounts_index.account_maps.iter().for_each(|i| {
.accounts_index i.read().unwrap().values().for_each(|entry| {
.account_maps entry
.iter() .slot_list
.map(|i| i.read().unwrap().values().cloned().collect::<Vec<_>>()) .read()
.flatten() .unwrap()
{ .iter()
for (_slot, account_entry) in account_entry.slot_list.read().unwrap().iter() { .for_each(|(_slot, account_entry)| {
let storage_entry_meta = stored_sizes_and_counts let storage_entry_meta = stored_sizes_and_counts
.entry(account_entry.store_id) .entry(account_entry.store_id)
.or_insert((0, 0)); .or_insert((0, 0));
storage_entry_meta.0 += account_entry.stored_size; storage_entry_meta.0 += account_entry.stored_size;
storage_entry_meta.1 += 1; storage_entry_meta.1 += 1;
} })
} })
});
for slot_stores in self.storage.0.iter() { for slot_stores in self.storage.0.iter() {
for (id, store) in slot_stores.value().read().unwrap().iter() { for (id, store) in slot_stores.value().read().unwrap().iter() {
// Should be default at this point // Should be default at this point