Skip to content

Commit

Permalink
Inline functions
Browse files Browse the repository at this point in the history
  • Loading branch information
febo committed Oct 4, 2024
1 parent b9b2a90 commit 2fa2358
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sdk/pinocchio/src/pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ pub const MAX_SEEDS: usize = 16;
/// [account]: https://solana.com/docs/core/accounts
pub type Pubkey = [u8; PUBKEY_BYTES];

/// Checks two pubkeys for equality in a computationally efficient way using
/// `sol_memcmp`.
/// Checks two pubkeys for equality using `sol_memcmp`.
///
/// Using `Pubkey::eq` (or `=`) is preferred over this function.
#[inline]
pub fn compare(a: &Pubkey, b: &Pubkey) -> bool {
// Safety:
//
// This method guarantees that the two arrays are of the same length.
unsafe { sol_memcmp(a, b, PUBKEY_BYTES) == 0 }
}

/// Copy `source` pubkey into `destination` in a computationally efficient way
/// using `sol_memcpy`.
/// Copy `source` pubkey into `destination` using `sol_memcpy`.
///
/// Using a standard assignment (e.g. `destination = source`) is preferred
/// over this function.
#[inline]
pub fn copy(destination: &mut Pubkey, source: &Pubkey) {
// Safety:
//
Expand All @@ -35,6 +40,7 @@ pub fn copy(destination: &mut Pubkey, source: &Pubkey) {
}

/// Log a `Pubkey` from a program
#[inline]
pub fn log(pubkey: &Pubkey) {
#[cfg(target_os = "solana")]
unsafe {
Expand Down

0 comments on commit 2fa2358

Please sign in to comment.