Skip to content

STYLE: Remove redundant input check from ExtractImageFilter#5319

Merged
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Remove-input-check-ExtractImageFilter
Apr 22, 2025
Merged

STYLE: Remove redundant input check from ExtractImageFilter#5319
dzenanz merged 1 commit intoInsightSoftwareConsortium:masterfrom
N-Dekker:Remove-input-check-ExtractImageFilter

Conversation

@N-Dekker
Copy link
Copy Markdown
Contributor

@N-Dekker N-Dekker commented Apr 22, 2025

ExtractImageFilter::GenerateOutputInformation() has returned already when the input is null. So the "cannot cast input" exception at the end of the member function will never occur anymore.


🤓 When reviewing, it may be helpful to ignore whitespace changes: https://github.com/InsightSoftwareConsortium/ITK/pull/5319/files?w=1

In the original code, you can see that the member function already does return earlier, when the input is null:

const typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
if (!outputPtr || !inputPtr)
{
return;
}
// Set the output image size to the same value as the extraction region.
outputPtr->SetLargestPossibleRegion(m_OutputImageRegion);
// Set the output spacing and origin
if (this->GetInput())

`ExtractImageFilter::GenerateOutputInformation()` has returned already when
the input is null. So the "cannot cast input" exception at the end of the
member function will never occur anymore.

Follow-up to pull request InsightSoftwareConsortium#4608
commit 6650d2c
"STYLE: Simplify code to remove unneeded dynamic_cast", Hans Johnson, May 1, 2024
@github-actions github-actions bot added area:Core Issues affecting the Core module type:Style Style changes: no logic impact (indentation, comments, naming) labels Apr 22, 2025
@N-Dekker N-Dekker marked this pull request as ready for review April 22, 2025 16:58
@dzenanz dzenanz merged commit bffff06 into InsightSoftwareConsortium:master Apr 22, 2025
16 checks passed
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 type:Style Style changes: no logic impact (indentation, comments, naming)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants