Skip to content

Commit 4a2713a

Browse files
committed
More hints
1 parent b90fe36 commit 4a2713a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

p-token/src/processor/shared/approve.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use {
22
crate::processor::validate_owner,
33
pinocchio::{
4-
account_info::AccountInfo, program_error::ProgramError, pubkey::pubkey_eq, ProgramResult,
4+
account_info::AccountInfo, hint::unlikely, program_error::ProgramError, pubkey::pubkey_eq,
5+
ProgramResult,
56
},
67
pinocchio_token_interface::{
78
error::TokenError,
@@ -58,15 +59,15 @@ pub fn process_approve(
5859
}
5960

6061
if let Some((mint_info, expected_decimals)) = expected_mint_info {
61-
if !pubkey_eq(mint_info.key(), &source_account.mint) {
62+
if unlikely(!pubkey_eq(mint_info.key(), &source_account.mint)) {
6263
return Err(TokenError::MintMismatch.into());
6364
}
6465

6566
// SAFETY: single immutable borrow of `mint_info` account data and
6667
// `load` validates that the mint is initialized.
6768
let mint = unsafe { load::<Mint>(mint_info.borrow_data_unchecked())? };
6869

69-
if expected_decimals != mint.decimals {
70+
if unlikely(expected_decimals != mint.decimals) {
7071
return Err(TokenError::MintDecimalsMismatch.into());
7172
}
7273
}

p-token/src/processor/unwrap_lamports.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use {
66
error::TokenError,
77
likely,
88
state::{account::Account, load_mut},
9+
unlikely,
910
},
1011
};
1112

@@ -61,7 +62,7 @@ pub fn process_unwrap_lamports(accounts: &[AccountInfo], instruction_data: &[u8]
6162
// raw pointer.
6263
let self_transfer = source_account_info == destination_account_info;
6364

64-
if self_transfer || amount == 0 {
65+
if unlikely(self_transfer || amount == 0) {
6566
// Validates the token account owner since we are not writing
6667
// to the account.
6768
check_account_owner(source_account_info)

0 commit comments

Comments
 (0)