From ed2c81ed95be71bace897e62a0c241068cfde7be Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Mon, 16 Apr 2018 00:16:02 +0100 Subject: replace std::list with std::vector on some hot paths also use reserve where appropriate --- src/wallet/wallet2.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/wallet/wallet2.cpp') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 98bd6c318..56a2a2adf 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1649,7 +1649,7 @@ void wallet2::parse_block_round(const cryptonote::blobdata &blob, cryptonote::bl bl_id = get_block_hash(bl); } //---------------------------------------------------------------------------------------------------- -void wallet2::pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, const std::list &short_chain_history, std::list &blocks, std::vector &o_indices) +void wallet2::pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, const std::list &short_chain_history, std::vector &blocks, std::vector &o_indices) { cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::request req = AUTO_VAL_INIT(req); cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::response res = AUTO_VAL_INIT(res); @@ -1700,7 +1700,7 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, o_indices = std::move(res.output_indices); } //---------------------------------------------------------------------------------------------------- -void wallet2::pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, const std::list &short_chain_history, std::list &hashes) +void wallet2::pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, const std::list &short_chain_history, std::vector &hashes) { cryptonote::COMMAND_RPC_GET_HASHES_FAST::request req = AUTO_VAL_INIT(req); cryptonote::COMMAND_RPC_GET_HASHES_FAST::response res = AUTO_VAL_INIT(res); @@ -1718,7 +1718,7 @@ void wallet2::pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, hashes = std::move(res.m_block_ids); } //---------------------------------------------------------------------------------------------------- -void wallet2::process_blocks(uint64_t start_height, const std::list &blocks, const std::vector &o_indices, uint64_t& blocks_added) +void wallet2::process_blocks(uint64_t start_height, const std::vector &blocks, const std::vector &o_indices, uint64_t& blocks_added) { size_t current_index = start_height; blocks_added = 0; @@ -1735,13 +1735,13 @@ void wallet2::process_blocks(uint64_t start_height, const std::list round_blocks(threads); std::deque error(threads); size_t blocks_size = blocks.size(); - std::list::const_iterator blocki = blocks.begin(); + std::vector::const_iterator blocki = blocks.begin(); for (size_t b = 0; b < blocks_size; b += threads) { size_t round_size = std::min((size_t)threads, blocks_size - b); tools::threadpool::waiter waiter; - std::list::const_iterator tmpblocki = blocki; + std::vector::const_iterator tmpblocki = blocki; for (size_t i = 0; i < round_size; ++i) { tpool.submit(&waiter, boost::bind(&wallet2::parse_block_round, this, std::cref(tmpblocki->block), @@ -1833,7 +1833,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched) refresh(start_height, blocks_fetched, received_money); } //---------------------------------------------------------------------------------------------------- -void wallet2::pull_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list &short_chain_history, const std::list &prev_blocks, std::list &blocks, std::vector &o_indices, bool &error) +void wallet2::pull_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list &short_chain_history, const std::vector &prev_blocks, std::vector &blocks, std::vector &o_indices, bool &error) { error = false; @@ -1843,7 +1843,7 @@ void wallet2::pull_next_blocks(uint64_t start_height, uint64_t &blocks_start_hei // prepend the last 3 blocks, should be enough to guard against a block or two's reorg cryptonote::block bl; - std::list::const_reverse_iterator i = prev_blocks.rbegin(); + std::vector::const_reverse_iterator i = prev_blocks.rbegin(); for (size_t n = 0; n < std::min((size_t)3, prev_blocks.size()); ++n) { bool ok = cryptonote::parse_and_validate_block_from_blob(i->block, bl); @@ -2110,7 +2110,7 @@ void wallet2::update_pool_state(bool refreshed) //---------------------------------------------------------------------------------------------------- void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list &short_chain_history) { - std::list hashes; + std::vector hashes; const uint64_t checkpoint_height = m_checkpoints.get_max_height(); if (stop_height > checkpoint_height && m_blockchain.size()-1 < checkpoint_height) @@ -2138,7 +2138,7 @@ void wallet2::fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, } if (hashes.size() + current_index < stop_height) { drop_from_short_history(short_chain_history, 3); - std::list::iterator right = hashes.end(); + std::vector::iterator right = hashes.end(); // prepend 3 more for (int i = 0; i<3; i++) { right--; @@ -2243,7 +2243,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re tools::threadpool& tpool = tools::threadpool::getInstance(); tools::threadpool::waiter waiter; uint64_t blocks_start_height; - std::list blocks; + std::vector blocks; std::vector o_indices; bool refreshed = false; @@ -2276,7 +2276,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re { // pull the next set of blocks while we're processing the current one uint64_t next_blocks_start_height; - std::list next_blocks; + std::vector next_blocks; std::vector next_o_indices; bool error = false; if (blocks.empty()) -- cgit v1.2.3