Browse Source

p-token: Bump pinocchio version (#91)

* Bump pinocchio version

* Use compiler hints from pinocchio
Fernando Otero 3 weeks ago
parent
commit
84fcb2817d

+ 2 - 2
Cargo.lock

@@ -3037,9 +3037,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
 
 [[package]]
 name = "pinocchio"
-version = "0.9.0"
+version = "0.9.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5123fe61ac87a327d434d530eaddaaf65069a37e33e5c9f798feaed29e4974c8"
+checksum = "5b971851087bc3699b001954ad02389d50c41405ece3548cbcafc88b3e20017a"
 
 [[package]]
 name = "pinocchio-log"

+ 1 - 1
Cargo.toml

@@ -36,7 +36,7 @@ consolidate-commits = false
 mollusk-svm = "0.4.0"
 mollusk-svm-fuzz-fixture = "0.4.0"
 num-traits = "0.2"
-pinocchio = "0.9"
+pinocchio = "0.9.2"
 solana-instruction = "2.3.0"
 solana-program-error = "2.2.2"
 solana-program-option = "2.2.1"

+ 0 - 32
p-interface/src/lib.rs

@@ -8,35 +8,3 @@ pub mod state;
 pub mod program {
     pinocchio_pubkey::declare_id!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
 }
-
-/// A "dummy" function with a hint to the compiler that it is unlikely to be
-/// called.
-///
-/// This function is used as a hint to the compiler to optimize other code paths
-/// instead of the one where the function is used.
-#[cold]
-pub const fn cold_path() {}
-
-/// Return the given `bool` value with a hint to the compiler that `true` is the
-/// likely case.
-#[inline(always)]
-pub const fn likely(b: bool) -> bool {
-    if b {
-        true
-    } else {
-        cold_path();
-        false
-    }
-}
-
-/// Return a given `bool` value with a hint to the compiler that `false` is the
-/// likely case.
-#[inline(always)]
-pub const fn unlikely(b: bool) -> bool {
-    if b {
-        cold_path();
-        true
-    } else {
-        false
-    }
-}

+ 1 - 2
p-interface/src/state/account.rs

@@ -1,7 +1,6 @@
 use {
     super::{account_state::AccountState, COption, Initializable, Transmutable},
-    crate::likely,
-    pinocchio::{program_error::ProgramError, pubkey::Pubkey},
+    pinocchio::{hint::likely, program_error::ProgramError, pubkey::Pubkey},
 };
 
 /// Incinerator address.

+ 1 - 2
p-token/src/processor/mod.rs

@@ -1,7 +1,7 @@
 use {
     core::{slice::from_raw_parts, str::from_utf8_unchecked},
     pinocchio::{
-        account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey,
+        account_info::AccountInfo, hint::unlikely, program_error::ProgramError, pubkey::Pubkey,
         syscalls::sol_memcpy_, ProgramResult,
     },
     pinocchio_token_interface::{
@@ -12,7 +12,6 @@ use {
             multisig::{Multisig, MAX_SIGNERS},
             Transmutable,
         },
-        unlikely,
     },
 };
 

+ 3 - 2
p-token/src/processor/shared/transfer.rs

@@ -1,10 +1,11 @@
 use {
     crate::processor::{check_account_owner, validate_owner},
-    pinocchio::{account_info::AccountInfo, program_error::ProgramError, ProgramResult},
+    pinocchio::{
+        account_info::AccountInfo, hint::unlikely, program_error::ProgramError, ProgramResult,
+    },
     pinocchio_token_interface::{
         error::TokenError,
         state::{account::Account, load, load_mut, load_mut_unchecked, mint::Mint},
-        unlikely,
     },
 };