avoid data copies in writing to cache (#23674)
This commit is contained in:
committed by
GitHub
parent
29af42f428
commit
b5a99b9b09
@ -57,7 +57,7 @@ use {
|
||||
solana_measure::measure::Measure,
|
||||
solana_rayon_threadlimit::get_thread_count,
|
||||
solana_sdk::{
|
||||
account::{AccountSharedData, ReadableAccount},
|
||||
account::{AccountSharedData, ReadableAccount, WritableAccount},
|
||||
clock::{BankId, Epoch, Slot, SlotCount},
|
||||
epoch_schedule::EpochSchedule,
|
||||
genesis_config::{ClusterType, GenesisConfig},
|
||||
@ -566,6 +566,19 @@ impl<'a> ReadableAccount for LoadedAccount<'a> {
|
||||
LoadedAccount::Cached(cached_account) => cached_account.account.rent_epoch(),
|
||||
}
|
||||
}
|
||||
fn to_account_shared_data(&self) -> AccountSharedData {
|
||||
match self {
|
||||
LoadedAccount::Stored(_stored_account_meta) => AccountSharedData::create(
|
||||
self.lamports(),
|
||||
self.data().to_vec(),
|
||||
*self.owner(),
|
||||
self.executable(),
|
||||
self.rent_epoch(),
|
||||
),
|
||||
// clone here to prevent data copy
|
||||
LoadedAccount::Cached(cached_account) => cached_account.account.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Debug)]
|
||||
|
Reference in New Issue
Block a user