Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Replace postfix by prefix increment in for loops in ITK/Modules #2499

Conversation

N-Dekker
Copy link
Contributor

Applied to ITK/Modules, at the GNU bash prompt:

find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*; .+); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

(Excluded ITK/Modules/ThirdParty.)

According to Herb Sutter, Andrei Alexandrescu - C++ Coding Standards:
101 Rules, Guidelines, and Best Practices: "Prefer the canonical form of
++ and --. Prefer calling the prefix forms"

Follow-up to:
pull request #2493
commit f81578b
"STYLE: Replace postfix by prefix increment in for loops in Core/Common"

Applied to ITK/Modules, at the GNU bash prompt:

    find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*; .+); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

(Excluded ITK/Modules/ThirdParty.)

According to Herb Sutter, Andrei Alexandrescu - C++ Coding Standards:
101 Rules, Guidelines, and Best Practices: "Prefer the canonical form of
++ and --. Prefer calling the prefix forms"

Follow-up to:
pull request InsightSoftwareConsortium#2493
commit f81578b
"STYLE: Replace postfix by prefix increment in `for` loops in Core/Common"
@N-Dekker
Copy link
Contributor Author

@dzenanz
Copy link
Member

dzenanz commented Apr 21, 2021

MacCI is working again. 😄

@N-Dekker
Copy link
Contributor Author

MacCI is working again.

I'm glad to hear so @dzenanz I guess MacCI has been waiting for us to fix those postfix increments 😸

@dzenanz
Copy link
Member

dzenanz commented Apr 21, 2021

No, it was fixed by #2492, but this is the first PR created since it was merged. I am glad the fix was simple 😄

@N-Dekker N-Dekker merged commit 971aef2 into InsightSoftwareConsortium:master Apr 23, 2021
N-Dekker added a commit to N-Dekker/ITK that referenced this pull request Apr 23, 2021
Applied to the root of ITK, at the GNU bash prompt:

    find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*;.*); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

(Excluded ITK/Modules/ThirdParty.)

Follow-up to:
pull request InsightSoftwareConsortium#2499
commit 971aef2
"STYLE: Replace postfix by prefix increment in for loops in ITK/Modules"
hjmjohnson pushed a commit that referenced this pull request Apr 23, 2021
Applied to the root of ITK, at the GNU bash prompt:

    find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*;.*); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

(Excluded ITK/Modules/ThirdParty.)

Follow-up to:
pull request #2499
commit 971aef2
"STYLE: Replace postfix by prefix increment in for loops in ITK/Modules"
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 20, 2021
Follows common C++ guidelines, including:

Google C++ Style Guide: "Use the prefix form (++i) of the increment and decrement operators unless you need postfix semantics."
https://google.github.io/styleguide/cppguide.html#Preincrement_and_Predecrement

Herb Sutter, Andrei Alexandrescu - C++ Coding Standards: 101 Rules, Guidelines, and Best Practices: "Prefer the canonical form of ++ and --. Prefer calling the prefix forms"
https://www.oreilly.com/library/view/c-coding-standards/0321113586/ch29.html

Anticipates "[clang-tidy] Add performance-prefer-preincrement check":
https://reviews.llvm.org/D72553

Corresponding ITK pull requests, which were merged in April 2021:
 - InsightSoftwareConsortium/ITK#2505
 - InsightSoftwareConsortium/ITK#2499
 - InsightSoftwareConsortium/ITK#2493
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 20, 2021
Applied to the root of elastix source tree, at the GNU bash prompt:

    $ find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*;.*); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

Follows common C++ guidelines, including:

Google C++ Style Guide: "Use the prefix form (++i) of the increment and decrement operators unless you need postfix semantics."
https://google.github.io/styleguide/cppguide.html#Preincrement_and_Predecrement

Herb Sutter, Andrei Alexandrescu - C++ Coding Standards: 101 Rules, Guidelines, and Best Practices: "Prefer the canonical form of ++ and --. Prefer calling the prefix forms"
https://www.oreilly.com/library/view/c-coding-standards/0321113586/ch29.html

Anticipates "[clang-tidy] Add performance-prefer-preincrement check":
https://reviews.llvm.org/D72553

Corresponding ITK pull requests, which were merged in April 2021:
 - InsightSoftwareConsortium/ITK#2505
 - InsightSoftwareConsortium/ITK#2499
 - InsightSoftwareConsortium/ITK#2493
N-Dekker added a commit to SuperElastix/elastix that referenced this pull request May 21, 2021
Applied to the root of elastix source tree, at the GNU bash prompt:

    $ find . \( -iname *.cxx -or -iname *.hxx -or -iname *.h \) -exec perl -pi -w -e 's/(\s+for \(.*;.*); (\w+)\+\+\)/$1; ++$2)/g;' {} \;

Follows common C++ guidelines, including:

Google C++ Style Guide: "Use the prefix form (++i) of the increment and decrement operators unless you need postfix semantics."
https://google.github.io/styleguide/cppguide.html#Preincrement_and_Predecrement

Herb Sutter, Andrei Alexandrescu - C++ Coding Standards: 101 Rules, Guidelines, and Best Practices: "Prefer the canonical form of ++ and --. Prefer calling the prefix forms"
https://www.oreilly.com/library/view/c-coding-standards/0321113586/ch29.html

Anticipates "[clang-tidy] Add performance-prefer-preincrement check":
https://reviews.llvm.org/D72553

Corresponding ITK pull requests, which were merged in April 2021:
 - InsightSoftwareConsortium/ITK#2505
 - InsightSoftwareConsortium/ITK#2499
 - InsightSoftwareConsortium/ITK#2493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants