simplify remove_if_slot_list_empty_value (#30436)
This commit is contained in:
parent
045b9fec11
commit
a78f763896
|
@ -2,7 +2,7 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
accounts_index::{
|
accounts_index::{
|
||||||
AccountMapEntry, AccountMapEntryInner, AccountMapEntryMeta, IndexValue,
|
AccountMapEntry, AccountMapEntryInner, AccountMapEntryMeta, IndexValue,
|
||||||
PreAllocatedAccountMapEntry, RefCount, SlotList, SlotSlice, UpsertReclaim, ZeroLamport,
|
PreAllocatedAccountMapEntry, RefCount, SlotList, UpsertReclaim, ZeroLamport,
|
||||||
},
|
},
|
||||||
bucket_map_holder::{Age, BucketMapHolder},
|
bucket_map_holder::{Age, BucketMapHolder},
|
||||||
bucket_map_holder_stats::BucketMapHolderStats,
|
bucket_map_holder_stats::BucketMapHolderStats,
|
||||||
|
@ -348,8 +348,8 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_if_slot_list_empty_value(&self, slot_list: SlotSlice<T>) -> bool {
|
fn remove_if_slot_list_empty_value(&self, is_empty: bool) -> bool {
|
||||||
if slot_list.is_empty() {
|
if is_empty {
|
||||||
self.stats().inc_delete();
|
self.stats().inc_delete();
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -368,8 +368,9 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
fn remove_if_slot_list_empty_entry(&self, entry: Entry<K, AccountMapEntry<T>>) -> bool {
|
fn remove_if_slot_list_empty_entry(&self, entry: Entry<K, AccountMapEntry<T>>) -> bool {
|
||||||
match entry {
|
match entry {
|
||||||
Entry::Occupied(occupied) => {
|
Entry::Occupied(occupied) => {
|
||||||
let result =
|
let result = self.remove_if_slot_list_empty_value(
|
||||||
self.remove_if_slot_list_empty_value(&occupied.get().slot_list.read().unwrap());
|
occupied.get().slot_list.read().unwrap().is_empty(),
|
||||||
|
);
|
||||||
if result {
|
if result {
|
||||||
// note there is a potential race here that has existed.
|
// note there is a potential race here that has existed.
|
||||||
// if someone else holds the arc,
|
// if someone else holds the arc,
|
||||||
|
@ -389,7 +390,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
match entry_disk {
|
match entry_disk {
|
||||||
Some(entry_disk) => {
|
Some(entry_disk) => {
|
||||||
// on disk
|
// on disk
|
||||||
if self.remove_if_slot_list_empty_value(&entry_disk.0) {
|
if self.remove_if_slot_list_empty_value(entry_disk.0.is_empty()) {
|
||||||
// not in cache, but on disk, so just delete from disk
|
// not in cache, but on disk, so just delete from disk
|
||||||
self.delete_disk_key(vacant.key());
|
self.delete_disk_key(vacant.key());
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in New Issue