Skip to content

Commit

Permalink
replace "slow zero-filled vec initialization"
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson authored and Lichtso committed Aug 25, 2023
1 parent c550044 commit 8a4f521
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions sdk/src/secp256k1_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,13 @@ pub fn new_secp256k1_instruction(
let signature_arr = signature.serialize();
assert_eq!(signature_arr.len(), SIGNATURE_SERIALIZED_SIZE);

let mut instruction_data = vec![];
instruction_data.resize(
DATA_START
.saturating_add(eth_pubkey.len())
.saturating_add(signature_arr.len())
.saturating_add(message_arr.len())
.saturating_add(1),
0,
);
let instruction_data_len = DATA_START
.saturating_add(eth_pubkey.len())
.saturating_add(signature_arr.len())
.saturating_add(message_arr.len())
.saturating_add(1);
let mut instruction_data = vec![0; instruction_data_len];

let eth_address_offset = DATA_START;
instruction_data[eth_address_offset..eth_address_offset.saturating_add(eth_pubkey.len())]
.copy_from_slice(&eth_pubkey);
Expand Down

0 comments on commit 8a4f521

Please sign in to comment.