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 ,
@@ -78,7 +82,7 @@ const MAX_FORMATTED_DIGITS: usize = u8::MAX as usize + 2;
7882/// Checks that the account is owned by the expected program.
7983#[ inline( always) ]
8084fn check_account_owner ( account_info : & AccountInfo ) -> ProgramResult {
81- if account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) {
85+ if likely ( account_info. is_owned_by ( & TOKEN_PROGRAM_ID ) ) {
8286 Ok ( ( ) )
8387 } else {
8488 Err ( ProgramError :: IncorrectProgramId )
@@ -100,7 +104,7 @@ unsafe fn validate_owner(
100104 owner_account_info : & AccountInfo ,
101105 signers : & [ AccountInfo ] ,
102106) -> ProgramResult {
103- if expected_owner != owner_account_info. key ( ) {
107+ if unlikely ( ! pubkey_eq ( expected_owner, owner_account_info. key ( ) ) ) {
104108 return Err ( TokenError :: OwnerMismatch . into ( ) ) ;
105109 }
106110
@@ -120,7 +124,7 @@ unsafe fn validate_owner(
120124
121125 for signer in signers. iter ( ) {
122126 for ( position, key) in multisig. signers [ 0 ..multisig. n as usize ] . iter ( ) . enumerate ( ) {
123- if key == signer. key ( ) && !matched[ position] {
127+ if pubkey_eq ( key, signer. key ( ) ) && !matched[ position] {
124128 if !signer. is_signer ( ) {
125129 return Err ( ProgramError :: MissingRequiredSignature ) ;
126130 }
0 commit comments