mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 10:08:53 +00:00
blockchain_db: allocate known size vector only once
This commit is contained in:
parent
6644b9b7b7
commit
ce594f5af7
@ -170,7 +170,7 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
|
|||||||
|
|
||||||
uint64_t tx_id = add_transaction_data(blk_hash, tx, tx_hash, tx_prunable_hash);
|
uint64_t tx_id = add_transaction_data(blk_hash, tx, tx_hash, tx_prunable_hash);
|
||||||
|
|
||||||
std::vector<uint64_t> amount_output_indices;
|
std::vector<uint64_t> amount_output_indices(tx.vout.size());
|
||||||
|
|
||||||
// iterate tx.vout using indices instead of C++11 foreach syntax because
|
// iterate tx.vout using indices instead of C++11 foreach syntax because
|
||||||
// we need the index
|
// we need the index
|
||||||
@ -183,13 +183,13 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
|
|||||||
cryptonote::tx_out vout = tx.vout[i];
|
cryptonote::tx_out vout = tx.vout[i];
|
||||||
rct::key commitment = rct::zeroCommit(vout.amount);
|
rct::key commitment = rct::zeroCommit(vout.amount);
|
||||||
vout.amount = 0;
|
vout.amount = 0;
|
||||||
amount_output_indices.push_back(add_output(tx_hash, vout, i, tx.unlock_time,
|
amount_output_indices[i] = add_output(tx_hash, vout, i, tx.unlock_time,
|
||||||
&commitment));
|
&commitment);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
amount_output_indices.push_back(add_output(tx_hash, tx.vout[i], i, tx.unlock_time,
|
amount_output_indices[i] = add_output(tx_hash, tx.vout[i], i, tx.unlock_time,
|
||||||
tx.version > 1 ? &tx.rct_signatures.outPk[i].mask : NULL));
|
tx.version > 1 ? &tx.rct_signatures.outPk[i].mask : NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_tx_amount_output_indices(tx_id, amount_output_indices);
|
add_tx_amount_output_indices(tx_id, amount_output_indices);
|
||||||
|
Loading…
Reference in New Issue
Block a user