11use {
22 core:: { slice:: from_raw_parts, str:: from_utf8_unchecked} ,
33 pinocchio:: {
4- account_info:: AccountInfo , hint:: unlikely, program_error:: ProgramError , pubkey:: Pubkey ,
5- syscalls:: sol_memcpy_, ProgramResult ,
4+ account_info:: AccountInfo ,
5+ hint:: likely,
6+ hint:: unlikely,
7+ program_error:: ProgramError ,
8+ pubkey:: { pubkey_eq, Pubkey } ,
9+ syscalls:: sol_memcpy_,
10+ ProgramResult ,
611 } ,
712 pinocchio_token_interface:: {
813 error:: TokenError ,
@@ -79,7 +84,7 @@ const MAX_FORMATTED_DIGITS: usize = u8::MAX as usize + 2;
7984/// Checks that the account is owned by the expected program.
8085#[ inline( always) ]
8186fn check_account_owner ( account_info : & AccountInfo ) -> ProgramResult {
82- if account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) {
87+ if likely ( account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) ) {
8388 Ok ( ( ) )
8489 } else {
8590 Err ( ProgramError :: IncorrectProgramId )
@@ -101,7 +106,7 @@ unsafe fn validate_owner(
101106 owner_account_info : & AccountInfo ,
102107 signers : & [ AccountInfo ] ,
103108) -> ProgramResult {
104- if expected_owner != owner_account_info. key ( ) {
109+ if unlikely ( ! pubkey_eq ( expected_owner, owner_account_info. key ( ) ) ) {
105110 return Err ( TokenError :: OwnerMismatch . into ( ) ) ;
106111 }
107112
@@ -121,7 +126,7 @@ unsafe fn validate_owner(
121126
122127 for signer in signers. iter ( ) {
123128 for ( position, key) in multisig. signers [ 0 ..multisig. n as usize ] . iter ( ) . enumerate ( ) {
124- if key == signer. key ( ) && !matched[ position] {
129+ if pubkey_eq ( key, signer. key ( ) ) && !matched[ position] {
125130 if !signer. is_signer ( ) {
126131 return Err ( ProgramError :: MissingRequiredSignature ) ;
127132 }
0 commit comments