Skip to content

Commit

Permalink
pr feedback: use write for maybe uninit, and avoid the copy
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Jan 28, 2025
1 parent 12e6572 commit abd03bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions program/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'a> SignatureVerification<'a> {
instructions_sysvar: &'a AccountInfo<'b>,
relative_index: i64,
) -> Result<[SignatureVerification<'a>; NUM_VERIFICATIONS], SlashingError> {
let mut verifications = [MaybeUninit::<SignatureVerification>::uninit(); NUM_VERIFICATIONS];
let mut verifications = [const {MaybeUninit::<SignatureVerification>::uninit()}; NUM_VERIFICATIONS];

// Instruction inspection to unpack successful signature verifications
let current_index = load_current_index_checked(instructions_sysvar)
Expand Down Expand Up @@ -179,9 +179,9 @@ impl<'a> SignatureVerification<'a> {
offsets.message_data_size as usize,
)?;

*verification =
MaybeUninit::new(SignatureVerification::new(pubkey, message, signature)?);
verification.write(SignatureVerification::new(pubkey, message, signature)?);
}
unsafe { std::mem::transmute_copy(&verifications) }
// Replace with `array_assume_init` once stabilized
Ok(verifications.map(|verification| unsafe {verification.assume_init()}))
}
}

0 comments on commit abd03bd

Please sign in to comment.