std::unordered_map::erase( const_iterator pos ) returns an iterator to the element following the removed one. Use that to optimize (probably minor-performance-wise, and definitely code-structure-wise) the implementation of CCoinsViewCache::BatchWrite().
Small refactor of CCoinsViewCache::BatchWrite() #11353
pull danra wants to merge 1 commits into bitcoin:master from danra:refactor/coins-view-cache-batch-write changing 1 files +48 −46-
danra commented at 3:54 PM on September 16, 2017: contributor
-
5b9748f979
Small refactor of CCoinsViewCache::BatchWrite()
std::unordered_map::erase( const_iterator pos ) returns an iterator to the element following the removed one. Use that to optimize (probably minor-performance-wise, and definitely code-structure-wise) the implementation of CCoinsViewCache::BatchWrite().
-
meshcollider commented at 3:53 AM on September 17, 2017: contributor
Note to reviewers, most of the diff is indentation change, so use ?w=1
Other than adding missing braces to some if-statements which is a style only change, basically all this change does is move the erasure from mapIndex from the end of the loop body into the brackets. @danra small changes like this aren't really that useful to be perfectly honest sorry, its time consuming to review things like this with almost no real benefit to it. It would be a lot more helpful if you wanted to help out in reviewing other, bigger PRs which are blockers for releases, since you obviously know the standards fairly well :)
-
sipa commented at 4:37 AM on September 17, 2017: member
@MeshCollider Thanks, adding
?w=1makes it look like a much more trivial refactor.utACK 5b9748f979dd65b229e2882e670794c46e2e720b
- fanquake added the label Refactoring on Sep 17, 2017
- dcousens approved
- gmaxwell approved
-
gmaxwell commented at 9:13 AM on September 18, 2017: contributor
ACK.
-
promag commented at 10:28 AM on September 18, 2017: member
IMO the only good change here is
it = mapCoins.erase(it). Adding braces because indentation, and indentation because of an early continue doesn't sound worth it. Don't get me wrong, but there are lots of other possible refactors like these and I think we don't want that to happen.That said, NACK as it is.
-
danra commented at 9:44 PM on September 18, 2017: contributor
It would be a lot more helpful if you wanted to help out in reviewing other, bigger PRs which are blockers for releases, since you obviously know the standards fairly well :)
I will/am. I'm posting smaller fixes as I'm learning the code.
its time consuming to review things like this with almost no real benefit to it.
Improving both the conciseness and the structure of the code, making it more accessible and easy to reason about, does have real benefit IMHO. @promag The main change isn't the indentation, it's the more concise
eraseoperation done in theforloop. Reducing indentation was a bonus. -
TheBlueMatt commented at 1:27 AM on September 21, 2017: member
utACK 5b9748f979dd65b229e2882e670794c46e2e720b
-
MarcoFalke commented at 7:24 PM on November 10, 2017: member
utACK 5b9748f97
- MarcoFalke merged this on Nov 10, 2017
- MarcoFalke closed this on Nov 10, 2017
- MarcoFalke referenced this in commit 05a761932e on Nov 10, 2017
- Fabcien referenced this in commit 6ffbbc121d on Aug 30, 2019
- PastaPastaPasta referenced this in commit adc66e70a7 on Jan 17, 2020
- PastaPastaPasta referenced this in commit a7b9dff07f on Jan 22, 2020
- PastaPastaPasta referenced this in commit a969c8d0be on Jan 22, 2020
- PastaPastaPasta referenced this in commit 77933a3846 on Jan 29, 2020
- ckti referenced this in commit 405967e2c2 on Mar 28, 2021
- furszy referenced this in commit 60d36292bc on Jul 26, 2021
- DrahtBot locked this on Sep 8, 2021