wallet2: speedup large tx construction: reserve vector memory
2.8 seconds -> 2.6 seconds on a test case
This commit is contained in:
parent
940811465f
commit
2eeb3fc1bf
|
@ -8583,6 +8583,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
|||
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request req_t = AUTO_VAL_INIT(req_t);
|
||||
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response resp_t = AUTO_VAL_INIT(resp_t);
|
||||
// request histogram for all outputs, except 0 if we have the rct distribution
|
||||
req_t.amounts.reserve(selected_transfers.size());
|
||||
for(size_t idx: selected_transfers)
|
||||
if (!m_transfers[idx].is_rct() || !has_rct_distribution)
|
||||
req_t.amounts.push_back(m_transfers[idx].is_rct() ? 0 : m_transfers[idx].amount());
|
||||
|
@ -8610,6 +8611,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
|||
{
|
||||
cryptonote::COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::request req_t = AUTO_VAL_INIT(req_t);
|
||||
cryptonote::COMMAND_RPC_GET_OUTPUT_DISTRIBUTION::response resp_t = AUTO_VAL_INIT(resp_t);
|
||||
req_t.amounts.reserve(req_t.amounts.size() + selected_transfers.size());
|
||||
for(size_t idx: selected_transfers)
|
||||
req_t.amounts.push_back(m_transfers[idx].is_rct() ? 0 : m_transfers[idx].amount());
|
||||
std::sort(req_t.amounts.begin(), req_t.amounts.end());
|
||||
|
@ -8688,6 +8690,8 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
|||
gamma.reset(new gamma_picker(rct_offsets));
|
||||
|
||||
size_t num_selected_transfers = 0;
|
||||
req.outputs.reserve(selected_transfers.size() * (base_requested_outputs_count + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW));
|
||||
daemon_resp.outs.reserve(selected_transfers.size() * (base_requested_outputs_count + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW));
|
||||
for(size_t idx: selected_transfers)
|
||||
{
|
||||
++num_selected_transfers;
|
||||
|
|
Loading…
Reference in New Issue