get rid of unneeded mut and refactor addref (#19594)

This commit is contained in:
Jeff Washington (jwash) 2021-09-03 10:45:37 -05:00 committed by GitHub
parent 205f070a99
commit df040c05da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -190,7 +190,7 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
.build()
}
pub fn slot_list(&mut self) -> &SlotList<T> {
pub fn slot_list(&self) -> &SlotList<T> {
&*self.borrow_slot_list_guard()
}
@ -201,10 +201,6 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
self.with_slot_list_guard_mut(user)
}
pub fn ref_count(&self) -> &AtomicU64 {
&self.borrow_owned_entry().ref_count
}
// create an entry that is equivalent to this process:
// 1. new empty (refcount=0, slot_list={})
// 2. update(slot, account_info)
@ -329,7 +325,7 @@ impl<T: IsCached> WriteAccountMapEntry<T> {
});
if addref {
// If it's the first non-cache insert, also bump the stored ref count
self.ref_count().fetch_add(1, Ordering::Relaxed);
self.borrow_owned_entry().add_un_ref(true);
}
}
}