No description provided.
Performance: Prefer prefix operator for non-primitive types #8579
pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1608-perfIter changing 26 files +62 −69-
MarcoFalke commented at 4:37 PM on August 24, 2016: member
-
Prefer prefix operator for non-primitive types fa18923432
- MarcoFalke added the label Refactoring on Aug 24, 2016
- MarcoFalke added the label Resource usage on Aug 24, 2016
-
paveljanik commented at 5:03 PM on August 24, 2016: contributor
Do you have some numbers? It would be nice to see some benchmarks added first and then comparing ++them with++ 👍
-
dcousens commented at 11:44 PM on August 24, 2016: contributor
utACK fa18923, but I really doubt this will be measurable.
-
MarcoFalke commented at 2:09 PM on August 25, 2016: member
This was suggested in #7656#discussion-diff-56476755, but apparently for base58 this has 0 effect, the bench binaries are identical. :laughing:
Some other hunks did not produce identical binaries, so in theory there could be a performance difference. Though, I don't think the performance gain matters in those other places.
- MarcoFalke closed this on Aug 25, 2016
- MarcoFalke deleted the branch on Aug 25, 2016
-
UdjinM6 commented at 2:19 PM on August 25, 2016: contributor
Not sure about specific cases here but in general performance gain could be quite significant: http://stackoverflow.com/a/9519095 Also it might simply be a good practice to use prefix operators by default and postfix only when needed imo.
-
sipa commented at 2:21 PM on August 25, 2016: member
In practice I expect this to have very little effect for containers with 'simple' iterators (where the iterator essentially consists of a single pointer). This is the case for
std::vector,std::list,std::set,std::map,std::multimap(but not forstd::vector<bool>orstd::deque). In this case, technically a copy is made before returning, but the compiler will just optimize it away if it is not used. -
paveljanik commented at 6:07 PM on August 25, 2016: contributor
Thank you for testing this Marco!
-
laanwj commented at 10:36 AM on August 26, 2016: member
Some other hunks did not produce identical binaries, so in theory there could be a performance difference. Though, I don't think the performance gain matters in those other places.
Even is changing it retroactively is not deemed worth it, let's try to encourage
++xisox++usage in new code, that's pretty uncontroversial. -
sipa commented at 10:41 AM on August 26, 2016: member
Even is changing it retroactively is not deemed worth it, let's try to encourage ++x iso x++ usage in new code, that's pretty uncontroversial.
Agree. Let's add that to
doc/developer-notes.md. - MarcoFalke locked this on Sep 8, 2021