Add constexpr to if when comparing dimensions, remove a few unnecessary static_cast's#5320
Merged
hjmjohnson merged 3 commits intoInsightSoftwareConsortium:masterfrom Apr 23, 2025
Merged
Conversation
Dimensions are already `unsigned int`, so these casts had no effect anyway. Replaced `static_cast<unsigned int>\(([A-Za-z]+Dimension)\)` with `$1`, using regular expressions. Replaced `static_cast<unsigned int>(Self::CellDimension)` with `CellDimension`.
When comparing one dimension with another, it is unnecessary to cast the two operands to `int`.
In ITK, the dimensions are typically known at compile-time.
dzenanz
approved these changes
Apr 23, 2025
N-Dekker
commented
Apr 23, 2025
Comment on lines
-60
to
-63
| if (inputPtr != nullptr && | ||
| static_cast<unsigned int>(InputImageDimension) == static_cast<unsigned int>(OutputImageDimension)) | ||
| if (inputPtr != nullptr && InputImageDimension == OutputImageDimension) | ||
| { | ||
| for (unsigned int i = 0; i < static_cast<unsigned int>(InputImageDimension); ++i) |
Contributor
Author
There was a problem hiding this comment.
All those static_cast<unsigned int>'s may look a bit silly nowadays, because a dimension is already unsigned int, but I think they were still meaningful for ITK 4, before C++11, when dimensions were represented by enum constants.
a674142
into
InsightSoftwareConsortium:master
16 checks passed
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
May 6, 2025
Following ITK pull request InsightSoftwareConsortium/ITK#5320 commit InsightSoftwareConsortium/ITK@9e533c4
N-Dekker
added a commit
to SuperElastix/elastix
that referenced
this pull request
May 6, 2025
Following ITK pull request InsightSoftwareConsortium/ITK#5320 commit InsightSoftwareConsortium/ITK@9e533c4
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A few style commits, using the fact that dimensions are defined as
constexpr unsigned int.