From 1c239a06a0e41656df84b7a466d412edc4f25722 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 9 Dec 2024 17:04:26 -0600 Subject: [PATCH] STYLE: Return quickly on first failure Short circuit return on first dimension test failure There is no need to test all dimensions. --- Modules/Core/Common/include/itkImageBase.hxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/Core/Common/include/itkImageBase.hxx b/Modules/Core/Common/include/itkImageBase.hxx index 9c4815b008c..0909730472f 100644 --- a/Modules/Core/Common/include/itkImageBase.hxx +++ b/Modules/Core/Common/include/itkImageBase.hxx @@ -371,8 +371,6 @@ template bool ImageBase::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. @@ -388,11 +386,10 @@ ImageBase::VerifyRequestedRegion() ((requestedRegionIndex[i] + static_cast(requestedRegionSize[i])) > (largestPossibleRegionIndex[i] + static_cast(largestPossibleRegionSize[i])))) { - retval = false; + return false; // Short circuit return on first dimension test failure. } } - - return retval; + return true; }