AcctIdx: insert goes directly to disk to avoid unnecessary allocations (#21490)

* AcctIdx: upsert avoids unnecessary allocation (during startup)

* feedback
This commit is contained in:
Jeff Washington (jwash)
2021-12-01 10:21:01 -06:00
committed by GitHub
parent cb368e6554
commit b108d7ddaa
2 changed files with 97 additions and 54 deletions

View File

@@ -292,6 +292,17 @@ pub enum PreAllocatedAccountMapEntry<T: IndexValue> {
Raw((Slot, T)),
}
impl<T: IndexValue> ZeroLamport for PreAllocatedAccountMapEntry<T> {
fn is_zero_lamport(&self) -> bool {
match self {
PreAllocatedAccountMapEntry::Entry(entry) => {
entry.slot_list.read().unwrap()[0].1.is_zero_lamport()
}
PreAllocatedAccountMapEntry::Raw(raw) => raw.1.is_zero_lamport(),
}
}
}
impl<T: IndexValue> From<PreAllocatedAccountMapEntry<T>> for (Slot, T) {
fn from(source: PreAllocatedAccountMapEntry<T>) -> (Slot, T) {
match source {