Task #54871
closedUse pre-increment and decrement operators
0%
Description
Variables can be incremented in pre style (+$i) or post style ($i+).
If the result of the operation is not assigned to a variable or otherwise directly used, pre should be used instead of post.
This is due to the fact that (under the hood) an extra variable assignment is taking place on post increment.
Yes it's a nano-opimization.
But I would like to see it used throughout the core as a 'best practice'.
Regex to find them: /[^=]\s*\$[a-zA-Z0-9]*(\+\+|\-\-)\s*;/
Updated by Georg Ringer almost 11 years ago
and what are the drawbacks?
if we change 1000s of lines, every backport will have troubles cause of merge conflicts which got us already into some releases with regressions.
can you give us some numbers of the benefit?
Updated by Mathias Schreiber almost 10 years ago
- Status changed from New to Closed
I think this qualifies for the same kind of code style issue like the vs = thing.
We just need to pay attention when reviewing code.
A huge change does not make sense here.