Skip to content

Commit 0f5dbb7

Browse files
committed
More hints
1 parent d12fefa commit 0f5dbb7

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
@@ -7,6 +7,7 @@ use {
77
pinocchio_token_interface::{
88
error::TokenError,
99
state::{account::Account, load_mut},
10+
unlikely,
1011
},
1112
};
1213

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

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

0 commit comments

Comments
 (0)