remove new alloc on deserialization (#15636)
This commit is contained in:
committed by
GitHub
parent
e7fd7d46cf
commit
6f5d8d18e9
@ -251,7 +251,10 @@ pub fn deserialize_parameters_aligned(
|
|||||||
+ size_of::<u8>() // executable
|
+ size_of::<u8>() // executable
|
||||||
+ 4 // padding to 128-bit aligned
|
+ 4 // padding to 128-bit aligned
|
||||||
+ size_of::<Pubkey>(); // key
|
+ size_of::<Pubkey>(); // key
|
||||||
account.owner = Pubkey::new(&buffer[start..start + size_of::<Pubkey>()]);
|
account
|
||||||
|
.owner
|
||||||
|
.as_mut()
|
||||||
|
.copy_from_slice(&buffer[start..start + size_of::<Pubkey>()]);
|
||||||
start += size_of::<Pubkey>(); // owner
|
start += size_of::<Pubkey>(); // owner
|
||||||
account.lamports = LittleEndian::read_u64(&buffer[start..]);
|
account.lamports = LittleEndian::read_u64(&buffer[start..]);
|
||||||
start += size_of::<u64>(); // lamports
|
start += size_of::<u64>(); // lamports
|
||||||
|
@ -325,6 +325,12 @@ impl AsRef<[u8]> for Pubkey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsMut<[u8]> for Pubkey {
|
||||||
|
fn as_mut(&mut self) -> &mut [u8] {
|
||||||
|
&mut self.0[..]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Pubkey {
|
impl fmt::Debug for Pubkey {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{}", bs58::encode(self.0).into_string())
|
write!(f, "{}", bs58::encode(self.0).into_string())
|
||||||
|
Reference in New Issue
Block a user