-
-
Notifications
You must be signed in to change notification settings - Fork 713
Replace var.Fill(x) with MakeFilled<T>(x)
#4924
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
Replace var.Fill(x) with MakeFilled<T>(x)
#4924
Conversation
Simply filled the elements of m_ShrinkFactorsPerLevel directly.
Using Notepad++, Replace in Files, doing:
Find what: ^( [ ]+)([^ ].*)[ ]+(\w+);[\r\n]+\1\3\.Fill\(
Replace with: $1auto $3 = MakeFilled<$2>\(
Filters: itk*.h;itk*.hxx;itk*.cxx
Directory: D:\src\ITK\Modules
[v] Match case
(*) Regular expression
Excluded "itkVectorMeanImageFunction.hxx", because it may try to fill a
`VariableLengthVector` (which is not supported by `MakeFilled`).
Follow-up to pull request InsightSoftwareConsortium#4891
commit d6c9eed
"STYLE: Replace Fill calls with `auto var = itk::MakeFilled<T>` in tests"
1c43f34 to
612e6b0
Compare
|
Note to self: After this PR, I hope I have some time to do follow-ups on the ITK SW Guide, examples, etc., as suggested by Jon at #4887 (review) |
|
|
||
| typename NeighborhoodIteratorType::RadiusType radius; | ||
| radius.Fill(1); | ||
| 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.
Should these now be "const auto" ?
I'm approving, and think this PR should not be held up to add const, but it might be another benefit of using MakeFilled.
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.
Should these now be "const auto" ?
Good question @hjmjohnson Actually maybe even "constexpr auto"!!! However, it's a bit risky to just blindly add const or constexpr to all such cases, as those variables might need to be modified later on. So I'm hoping that this can be achieved by a follow-up PR, using some intelligent code analysis tool, which checks that those variables aren't modified after their initialization 😃
Thanks for your approval!
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)
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
#4924 (comment)
- Following ITK pull request InsightSoftwareConsortium/ITK#4924 commit InsightSoftwareConsortium/ITK@6cb6bf9
- Following ITK pull request InsightSoftwareConsortium/ITK#4924 commit InsightSoftwareConsortium/ITK@6cb6bf9
- Following ITK pull request InsightSoftwareConsortium/ITK#4924 commit InsightSoftwareConsortium/ITK@6cb6bf9
auto var = itk::MakeFilled<T>in tests #4891Also removed the local
shrinkFactorsvariable from the default-constructor ofImageRegistrationMethodv4, and instead, simply "filled" the elements of itsm_ShrinkFactorsPerLeveldirectly.