-
-
Notifications
You must be signed in to change notification settings - Fork 686
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
STYLE: Replace postfix by prefix increment in for
loops in ITK/Modules
#2499
Conversation
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"
Nice video by Fred Overflow (@fredoverflow) on this topic: Why C++ programmers prefer ++i over i++ (prefix vs. postfix increment operator, for loop, iterators) --> www.youtube.com/watch?v=bONciSOJ_N4 |
MacCI is working again. 😄 |
I'm glad to hear so @dzenanz I guess MacCI has been waiting for us to fix those postfix increments 😸 |
No, it was fixed by #2492, but this is the first PR created since it was merged. I am glad the fix was simple 😄 |
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"
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"
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
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
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
Applied to ITK/Modules, at the GNU bash prompt:
(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"