diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-01 14:06:12 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-01 14:06:12 +0100 |
commit | 5d4ef719b9763ce9c150b93d61e541f5bbc1bbb9 (patch) | |
tree | 3a021261fdba3e29fda6a43f4bc3bf4f69136e87 /src/cryptonote_core | |
parent | perf_timer: allow profiling more granular than millisecond (diff) | |
download | monero-5d4ef719b9763ce9c150b93d61e541f5bbc1bbb9.tar.xz |
core: speed up output index unique set calculation
A sort+uniq step was done for every tx in a 200 block chunk,
causing a lot of repeated scanning as the size of the offset
map got larger with every added tx. We now do the step only
once at the end of the loop.
Doing it this way potentially uses more memory, but testing
shows that it's currently only about 2% more.
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 745608b9f..2420adc53 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -3866,17 +3866,17 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e offset_map[in_to_key.amount].push_back(offset); } - - // sort and remove duplicate absolute_offsets in offset_map - for (auto &offsets : offset_map) - { - std::sort(offsets.second.begin(), offsets.second.end()); - auto last = std::unique(offsets.second.begin(), offsets.second.end()); - offsets.second.erase(last, offsets.second.end()); - } } } + // sort and remove duplicate absolute_offsets in offset_map + for (auto &offsets : offset_map) + { + std::sort(offsets.second.begin(), offsets.second.end()); + auto last = std::unique(offsets.second.begin(), offsets.second.end()); + offsets.second.erase(last, offsets.second.end()); + } + // [output] stores all transactions for each tx_out_index::hash found std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size()); |