From e5be96d8bf6eb82e3742eada5aeaeef9b1bccbde Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Wed, 15 Dec 2021 15:39:54 -0600 Subject: [PATCH] AcctIdx: consolidate next_id calls (#21929) --- runtime/src/accounts_db.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 53b5ff4ad0..97b0cd0ef2 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1714,13 +1714,14 @@ impl AccountsDb { } } + fn next_id(&self) -> AppendVecId { + let next_id = self.next_id.fetch_add(1, Ordering::AcqRel); + assert!(next_id != AppendVecId::MAX, "We've run out of storage ids!"); + next_id + } + fn new_storage_entry(&self, slot: Slot, path: &Path, size: u64) -> AccountStorageEntry { - AccountStorageEntry::new( - path, - slot, - self.next_id.fetch_add(1, Ordering::AcqRel), - size, - ) + AccountStorageEntry::new(path, slot, self.next_id(), size) } pub fn expected_cluster_type(&self) -> ClusterType { @@ -3732,7 +3733,7 @@ impl AccountsDb { let ret = recycle_stores.remove_entry(i); drop(recycle_stores); let old_id = ret.append_vec_id(); - ret.recycle(slot, self.next_id.fetch_add(1, Ordering::AcqRel)); + ret.recycle(slot, self.next_id()); debug!( "recycling store: {} {:?} old_id: {}", ret.append_vec_id(),