From 964d23ff186b5d67665a0344de87b470b787487d Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Mon, 2 Jan 2023 09:41:36 -0600 Subject: [PATCH] cleanup 'shrinking_in_progress' (#29359) --- runtime/src/account_storage.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/runtime/src/account_storage.rs b/runtime/src/account_storage.rs index 1fc96030350644..4ea27fc1fe1f07 100644 --- a/runtime/src/account_storage.rs +++ b/runtime/src/account_storage.rs @@ -83,22 +83,13 @@ impl AccountStorage { /// called when shrinking begins on a slot and append vec. /// When 'ShrinkInProgress' is dropped by caller, the old store will be removed from the storage map. + /// Fails if there are no existing stores at the slot. pub(crate) fn shrinking_in_progress( &self, slot: Slot, new_store: Arc, ) -> ShrinkInProgress<'_> { - let slot_storages: SlotStores = self.get_slot_stores(slot).unwrap_or_else(|| - // DashMap entry.or_insert() returns a RefMut, essentially a write lock, - // which is dropped after this block ends, minimizing time held by the lock. - // However, we still want to persist the reference to the `SlotStores` behind - // the lock, hence we clone it out, (`SlotStores` is an Arc so is cheap to clone). - self - .map - .entry(slot) - .or_insert(Arc::new(RwLock::new(HashMap::new()))) - .clone()); - + let slot_storages = self.get_slot_stores(slot).unwrap(); let shrinking_store = Arc::clone(slot_storages.read().unwrap().iter().next().unwrap().1); let new_id = new_store.append_vec_id();