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, unlikely} ,
6+ program_error:: ProgramError ,
7+ pubkey:: { pubkey_eq, Pubkey } ,
8+ syscalls:: sol_memcpy_,
9+ ProgramResult ,
610 } ,
711 pinocchio_token_interface:: {
812 error:: TokenError ,
@@ -79,7 +83,7 @@ const MAX_FORMATTED_DIGITS: usize = u8::MAX as usize + 2;
7983/// Checks that the account is owned by the expected program.
8084#[ inline( always) ]
8185fn check_account_owner ( account_info : & AccountInfo ) -> ProgramResult {
82- if account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) {
86+ if likely ( account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) ) {
8387 Ok ( ( ) )
8488 } else {
8589 Err ( ProgramError :: IncorrectProgramId )
@@ -101,7 +105,7 @@ unsafe fn validate_owner(
101105 owner_account_info : & AccountInfo ,
102106 signers : & [ AccountInfo ] ,
103107) -> ProgramResult {
104- if expected_owner != owner_account_info. key ( ) {
108+ if unlikely ( ! pubkey_eq ( expected_owner, owner_account_info. key ( ) ) ) {
105109 return Err ( TokenError :: OwnerMismatch . into ( ) ) ;
106110 }
107111
@@ -121,7 +125,7 @@ unsafe fn validate_owner(
121125
122126 for signer in signers. iter ( ) {
123127 for ( position, key) in multisig. signers [ 0 ..multisig. n as usize ] . iter ( ) . enumerate ( ) {
124- if key == signer. key ( ) && !matched[ position] {
128+ if pubkey_eq ( key, signer. key ( ) ) && !matched[ position] {
125129 if !signer. is_signer ( ) {
126130 return Err ( ProgramError :: MissingRequiredSignature ) ;
127131 }
0 commit comments