Project

General

Profile

Actions

Task #54871

closed

Use pre-increment and decrement operators

Added by Michiel Roos almost 11 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2014-01-09
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
no-brainer
Sprint Focus:

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*;/

Actions #1

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?

Actions #2

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.

Actions

Also available in: Atom PDF