11use {
22 core:: { slice:: from_raw_parts, str:: from_utf8_unchecked} ,
33 pinocchio:: {
4- account_info:: AccountInfo , program_error:: ProgramError , pubkey:: Pubkey ,
5- syscalls:: sol_memcpy_, ProgramResult ,
4+ account_info:: AccountInfo ,
5+ hint:: likely,
6+ program_error:: ProgramError ,
7+ pubkey:: { pubkey_eq, Pubkey } ,
8+ syscalls:: sol_memcpy_,
9+ ProgramResult ,
610 } ,
711 pinocchio_token_interface:: {
812 error:: TokenError ,
@@ -80,7 +84,7 @@ const MAX_FORMATTED_DIGITS: usize = u8::MAX as usize + 2;
8084/// Checks that the account is owned by the expected program.
8185#[ inline( always) ]
8286fn check_account_owner ( account_info : & AccountInfo ) -> ProgramResult {
83- if account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) {
87+ if likely ( account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) ) {
8488 Ok ( ( ) )
8589 } else {
8690 Err ( ProgramError :: IncorrectProgramId )
@@ -102,7 +106,7 @@ unsafe fn validate_owner(
102106 owner_account_info : & AccountInfo ,
103107 signers : & [ AccountInfo ] ,
104108) -> ProgramResult {
105- if expected_owner != owner_account_info. key ( ) {
109+ if unlikely ( ! pubkey_eq ( expected_owner, owner_account_info. key ( ) ) ) {
106110 return Err ( TokenError :: OwnerMismatch . into ( ) ) ;
107111 }
108112
@@ -122,7 +126,7 @@ unsafe fn validate_owner(
122126
123127 for signer in signers. iter ( ) {
124128 for ( position, key) in multisig. signers [ 0 ..multisig. n as usize ] . iter ( ) . enumerate ( ) {
125- if key == signer. key ( ) && !matched[ position] {
129+ if pubkey_eq ( key, signer. key ( ) ) && !matched[ position] {
126130 if !signer. is_signer ( ) {
127131 return Err ( ProgramError :: MissingRequiredSignature ) ;
128132 }
0 commit comments