-
-
Notifications
You must be signed in to change notification settings - Fork 713
STYLE: Add constexpr to variables initialized by MakeFilled #4930
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: Add constexpr to variables initialized by MakeFilled #4930
Conversation
Suggests evaluating its value at compile-time, rather than at runtime.
Found by regular expressions:
^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(-?\d+\);)
^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(\d.0\);)
^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(false\);)
^( [ ]+)(auto \w+[ ]+= MakeFilled<.+>\(true\);)
Inspired by a comment by Hans Johnson at
InsightSoftwareConsortium#4924 (comment)
hjmjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love It !!!
|
|
||
| // Build and setup the neighborhood iterator | ||
| auto radius = MakeFilled<typename NeighborhoodIteratorType::RadiusType>(1); | ||
| constexpr auto radius = MakeFilled<typename NeighborhoodIteratorType::RadiusType>(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even declare those variables static constexpr, instead of just non-static constexpr. I don't know if it matters much, in these cases 🤷 Some people prefer to always declare local variables static constexpr if possible.
|
FYI This PR has excluded variables that could not be declared |
|
/azp run ITK.Linux |
Found by the regular expression `^( [ ]+)(auto \w+[ ]+= .+::Filled\(\d+\);)`
Manually excluded cases that did not compile, in
itkLabelMapContourOverlayImageFilter.hxx
itkBSplineControlPointImageFilter.hxx
itkBSplineScatteredDataPointSetToImageFilter.hxx
itkTileImageFilter.hxx
itkFFTDiscreteGaussianImageFilter.hxx
itkSLICImageFilter.hxx
- Follow-up to pull request InsightSoftwareConsortium#4930
commit fd14482
"STYLE: Add constexpr to variables initialized by MakeFilled"
Found by the regular expression `^( [ ]+)(auto \w+[ ]+= .+::Filled\(\d+\);)`
Manually excluded cases that did not compile, in
itkLabelMapContourOverlayImageFilter.hxx
itkBSplineControlPointImageFilter.hxx
itkBSplineScatteredDataPointSetToImageFilter.hxx
itkTileImageFilter.hxx
itkFFTDiscreteGaussianImageFilter.hxx
itkSLICImageFilter.hxx
- Follow-up to pull request InsightSoftwareConsortium#4930
commit fd14482
"STYLE: Add constexpr to variables initialized by MakeFilled"
Using Notepad++, Replace in Files, doing:
Find what: ^( [ ]+)(auto \w+[ ]+= .+::Filled\(\d+\);)
Replace with: $1constexpr $2
Filters: itk*.* !+\test
Directory: D:\src\ITK\Modules
[v] Match case
(*) Regular expression
Manually excluded cases that did not compile, in
itkLabelMapContourOverlayImageFilter.hxx
itkBSplineControlPointImageFilter.hxx
itkBSplineScatteredDataPointSetToImageFilter.hxx
itkTileImageFilter.hxx
itkFFTDiscreteGaussianImageFilter.hxx
itkSLICImageFilter.hxx
- Follow-up to pull request InsightSoftwareConsortium#4930
commit fd14482
"STYLE: Add constexpr to variables initialized by MakeFilled"
Using Notepad++, Replace in Files, doing:
Find what: ^( [ ]+)(auto \w+[ ]+= .+::Filled\(\d+\);)
Replace with: $1constexpr $2
Filters: itk*.* !+\test
Directory: D:\src\ITK\Modules
[v] Match case
(*) Regular expression
Manually excluded cases that did not compile, in
itkLabelMapContourOverlayImageFilter.hxx
itkBSplineControlPointImageFilter.hxx
itkBSplineScatteredDataPointSetToImageFilter.hxx
itkTileImageFilter.hxx
itkFFTDiscreteGaussianImageFilter.hxx
itkSLICImageFilter.hxx
- Follow-up to pull request #4930
commit fd14482
"STYLE: Add constexpr to variables initialized by MakeFilled"
Suggests evaluating its value at compile-time, rather than at runtime.
Found by regular expressions:
Inspired by a comment by Hans Johnson (@hjmjohnson) at
#4924 (comment)