[trivial][doc] Mention ++i as preferred over i++ in dev notes #8602
pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:trvial-dev-notes changing 1 files +4 −3-
fanquake commented at 11:41 AM on August 26, 2016: member
-
[trivial][doc] Mention ++i as preferred to i++ in dev notes ab53207b9c
-
sipa commented at 11:47 AM on August 26, 2016: member
utACK
-
laanwj commented at 12:33 PM on August 26, 2016: member
- laanwj merged this on Aug 26, 2016
- laanwj closed this on Aug 26, 2016
- laanwj referenced this in commit bb566761fb on Aug 26, 2016
-
in doc/developer-notes.md:None in ab53207b9c
13 | @@ -14,6 +14,7 @@ gradually. 14 | - No indentation for public/protected/private or for namespaces. 15 | - No extra spaces inside parenthesis; don't do ( this ) 16 | - No space after function names; one space after if, for and while. 17 | + - `++i` is preferred over `i++`.
MarcoFalke commented at 6:00 PM on August 26, 2016:Nit: Sorry to nitpick this after merge, but I'd rather put it in the section General C++ (line 253) and also mention that
i++is fine for integers.You can copy the rationale from the cpp guide
When the return value is ignored, the "pre" form (++i) is never less efficient than the "post" form (i++), and is often more efficient. This is because post-increment (or decrement) requires a copy of i to be made, which is the value of the expression. If i is an iterator or other non-scalar type, copying i could be expensive. Since the two types of increment behave the same when the value is ignored, why not just always pre-increment?
sipa commented at 6:02 PM on August 26, 2016:I agree here. This is not just a style issue, as it may affect generated code.
codablock referenced this in commit 4b90f0fa94 on Sep 19, 2017codablock referenced this in commit 8c59d16dca on Jan 9, 2018codablock referenced this in commit 87c81ba6f9 on Jan 9, 2018andvgal referenced this in commit 88437564e7 on Jan 6, 2019fanquake deleted the branch on Jan 22, 2020DrahtBot locked this on Feb 15, 2022
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:15 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me