avoid data copies in writing to cache (#23674)
This commit is contained in:
committed by
GitHub
parent
29af42f428
commit
b5a99b9b09
@ -253,6 +253,10 @@ impl ReadableAccount for AccountSharedData {
|
||||
fn rent_epoch(&self) -> Epoch {
|
||||
self.rent_epoch
|
||||
}
|
||||
fn to_account_shared_data(&self) -> AccountSharedData {
|
||||
// avoid data copy here
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ReadableAccount for Ref<'_, AccountSharedData> {
|
||||
@ -271,6 +275,16 @@ impl ReadableAccount for Ref<'_, AccountSharedData> {
|
||||
fn rent_epoch(&self) -> Epoch {
|
||||
self.rent_epoch
|
||||
}
|
||||
fn to_account_shared_data(&self) -> AccountSharedData {
|
||||
AccountSharedData {
|
||||
lamports: self.lamports(),
|
||||
// avoid data copy here
|
||||
data: Arc::clone(&self.data),
|
||||
owner: *self.owner(),
|
||||
executable: self.executable(),
|
||||
rent_epoch: self.rent_epoch(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ReadableAccount for Ref<'_, Account> {
|
||||
|
Reference in New Issue
Block a user