BorrowedAccount: reserve() doesn't need to check for can_data_be_changed() (#32642)

reserve() only changes the capacity of the vector that holds the account data,
it doesn't modify the account in any way
This commit is contained in:
Alessandro Decina 2023-07-28 14:10:43 +07:00 committed by GitHub
parent de02601d73
commit 029f7b1d56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -964,7 +964,10 @@ impl<'a> BorrowedAccount<'a> {
/// in the given account. Does nothing if capacity is already sufficient.
#[cfg(not(target_os = "solana"))]
pub fn reserve(&mut self, additional: usize) -> Result<(), InstructionError> {
self.can_data_be_changed()?;
// Note that we don't need to call can_data_be_changed() here nor
// touch() the account. reserve() only changes the capacity of the
// memory that holds the account but it doesn't actually change content
// nor length of the account.
self.make_data_mut();
self.account.reserve(additional);