-
-
Notifications
You must be signed in to change notification settings - Fork 668
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 T var; var = x
with T var = x
for arithmetic types
#4932
Merged
dzenanz
merged 1 commit into
InsightSoftwareConsortium:master
from
N-Dekker:Replace-declaration-assignment-of-scalars
Nov 6, 2024
Merged
STYLE: Replace T var; var = x
with T var = x
for arithmetic types
#4932
dzenanz
merged 1 commit into
InsightSoftwareConsortium:master
from
N-Dekker:Replace-declaration-assignment-of-scalars
Nov 6, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
type:Testing
Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
area:Core
Issues affecting the Core module
area:Filtering
Issues affecting the Filtering module
area:IO
Issues affecting the IO module
area:Segmentation
Issues affecting the Segmentation module
type:Style
Style changes: no logic impact (indentation, comments, naming)
area:Numerics
Issues affecting the Numerics module
labels
Nov 5, 2024
hjmjohnson
approved these changes
Nov 5, 2024
Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object", https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)([a-z][a-z ]*[a-z])([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Excluded `delete` statements, even if they would match the regular expression (as in `delete var; var = x`).
N-Dekker
force-pushed
the
Replace-declaration-assignment-of-scalars
branch
from
November 5, 2024 15:06
1666742
to
5d0df7a
Compare
github-actions
bot
added
the
area:Registration
Issues affecting the Registration module
label
Nov 5, 2024
N-Dekker
changed the title
STYLE: Replace
STYLE: Replace Nov 5, 2024
T var; var = x
with T var = x
for scalars in testsT var; var = x
with T var = x
for arithmetic types
dzenanz
approved these changes
Nov 5, 2024
Is this "ready for review"? If so, I think it can be merged. |
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 6, 2024
Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)([^ ].*\*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Excluded an unrelated case from "itkMINCImageIO.cxx" (`_sep = -_sep`), which accidentally matched the regular expression. - Follow-up to pull request InsightSoftwareConsortium#4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 7, 2024
Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)([^ ].*\*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Manually excluded an unrelated case from "itkMINCImageIO.cxx" (`_sep = -_sep`), which accidentally matched the regular expression. - Follow-up to pull request InsightSoftwareConsortium#4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 7, 2024
Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)([^ ].*\*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Manually excluded an unrelated case from "itkMINCImageIO.cxx" (`_sep = -_sep`), which accidentally matched the regular expression. - Follow-up to pull request InsightSoftwareConsortium#4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
hjmjohnson
pushed a commit
that referenced
this pull request
Nov 7, 2024
Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)([^ ].*\*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Manually excluded an unrelated case from "itkMINCImageIO.cxx" (`_sep = -_sep`), which accidentally matched the regular expression. - Follow-up to pull request #4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
N-Dekker
added a commit
to N-Dekker/ITK
that referenced
this pull request
Nov 7, 2024
For Standard Library types that have a non-trivial default-constructor and a non-trivial assignment operator, `T var = x` is typically slightly faster than `T var; var = x`. Otherwise it's just a matter of style. Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)(std::[^ ]*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Follow-up to pull request InsightSoftwareConsortium#4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
hjmjohnson
pushed a commit
that referenced
this pull request
Nov 9, 2024
For Standard Library types that have a non-trivial default-constructor and a non-trivial assignment operator, `T var = x` is typically slightly faster than `T var; var = x`. Otherwise it's just a matter of style. Using Notepad++, Replace in Files, doing: Find what: ^( [ ]+)(std::[^ ]*)([ ]+)(\w+);[\r\n]+\1\4\ = Replace with: $1$2$3$4 = Filters: itk*.* Directory: D:\src\ITK\Modules [v] Match case (*) Regular expression Follow-up to pull request #4932 commit 5b121f4 "STYLE: Replace `T var; var = x` with `T var = x` for arithmetic types"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:Core
Issues affecting the Core module
area:Filtering
Issues affecting the Filtering module
area:IO
Issues affecting the IO module
area:Numerics
Issues affecting the Numerics module
area:Registration
Issues affecting the Registration module
area:Segmentation
Issues affecting the Segmentation module
type:Style
Style changes: no logic impact (indentation, comments, naming)
type:Testing
Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following C++ Core Guidelines, Oct 3, 2024, "Always initialize an object"
Using Notepad++, Replace in Files, doing:
Excluded
delete
statements, even if they would match the regular expression (as indelete var; var = x
).The regular expression worked well in almost all cases. Almost... but here is an example where it went wrong, accidentally:
ITK/Modules/Core/Common/src/itkSingleton.cxx
Lines 48 to 49 in d37e7b4
Would be reduced to one line of code:
Such accidental cases were manually excluded.