One less alloc per transaction (#9705)

* One less alloc per transaction

* Fix benches

* Fix compiler warnings in bench build

* Fix move build

* Fix bench
This commit is contained in:
Greg Fitzgerald
2020-04-24 13:03:46 -06:00
committed by GitHub
parent 767a0f9384
commit 76b1c2baf0
24 changed files with 95 additions and 106 deletions

View File

@ -5431,7 +5431,7 @@ pub mod tests {
let vote_ix = vote_instruction::vote(&keypair.pubkey(), &keypair.pubkey(), vote);
let vote_tx =
Transaction::new_signed_instructions(&[keypair], vec![vote_ix], Hash::default());
Transaction::new_signed_instructions(&[keypair], &[vote_ix], Hash::default());
vote_entries.push(next_entry_mut(&mut Hash::default(), 0, vec![vote_tx]));
let mut tick = create_ticks(1, 0, hash(&serialize(&i).unwrap()));

View File

@ -490,19 +490,19 @@ mod tests {
let budget_contract = Keypair::new();
let budget_pubkey = budget_contract.pubkey();
let ixs = budget_instruction::payment(&pubkey, &pubkey, &budget_pubkey, 1);
Transaction::new_signed_instructions(&[keypair, &budget_contract], ixs, hash)
Transaction::new_signed_instructions(&[keypair, &budget_contract], &ixs, hash)
}
fn create_sample_timestamp(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ix = budget_instruction::apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
Transaction::new_signed_instructions(&[keypair], vec![ix], hash)
Transaction::new_signed_instructions(&[keypair], &[ix], hash)
}
fn create_sample_apply_signature(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ix = budget_instruction::apply_signature(&pubkey, &pubkey, &pubkey);
Transaction::new_signed_instructions(&[keypair], vec![ix], hash)
Transaction::new_signed_instructions(&[keypair], &[ix], hash)
}
#[test]

View File

@ -134,7 +134,7 @@ pub(crate) mod tests {
amount: u64,
) {
let vote_pubkey = vote_account.pubkey();
fn process_instructions<T: Signers>(bank: &Bank, keypairs: &T, ixs: Vec<Instruction>) {
fn process_instructions<T: Signers>(bank: &Bank, keypairs: &T, ixs: &[Instruction]) {
let tx = Transaction::new_signed_with_payer(
ixs,
Some(&keypairs.pubkeys()[0]),
@ -147,7 +147,7 @@ pub(crate) mod tests {
process_instructions(
bank,
&[from_account, vote_account, validator_identity_account],
vote_instruction::create_account(
&vote_instruction::create_account(
&from_account.pubkey(),
&vote_pubkey,
&VoteInit {
@ -166,7 +166,7 @@ pub(crate) mod tests {
process_instructions(
bank,
&[from_account, &stake_account_keypair],
stake_instruction::create_account_and_delegate_stake(
&stake_instruction::create_account_and_delegate_stake(
&from_account.pubkey(),
&stake_account_pubkey,
&vote_pubkey,