Skip to content

Commit

Permalink
STYLE: Return quickly on first failure
Browse files Browse the repository at this point in the history
Short circuit return on first dimension test failure

There is no need to test all dimensions.
  • Loading branch information
hjmjohnson committed Dec 11, 2024
1 parent 56dd6e2 commit 1c239a0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Modules/Core/Common/include/itkImageBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@ template <unsigned int VImageDimension>
bool
ImageBase<VImageDimension>::VerifyRequestedRegion()
{
bool retval = true;

// Is the requested region within the LargestPossibleRegion?
// Note that the test is indeed against the largest possible region
// rather than the buffered region; see DataObject::VerifyRequestedRegion.
Expand All @@ -388,11 +386,10 @@ ImageBase<VImageDimension>::VerifyRequestedRegion()
((requestedRegionIndex[i] + static_cast<OffsetValueType>(requestedRegionSize[i])) >
(largestPossibleRegionIndex[i] + static_cast<OffsetValueType>(largestPossibleRegionSize[i]))))
{
retval = false;
return false; // Short circuit return on first dimension test failure.
}
}

return retval;
return true;
}


Expand Down

0 comments on commit 1c239a0

Please sign in to comment.