Skip to content

Commit

Permalink
STYLE: Remove extra processing return quickly when result is known
Browse files Browse the repository at this point in the history
Simplify the code by returning as soon as the condition is known to be
false.
Remove unnecessary "ok" temporary variable.
  • Loading branch information
hjmjohnson committed Nov 22, 2024
1 parent 27f1b1f commit fb07d52
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,32 +177,22 @@ VoronoiSegmentationRGBImageFilter<TInputImage, TOutputImage>::TestHomogeneity(In
}
}

bool ok = true;
j = 0;
double savem, savev;
while (ok && (j < 3))
while ((j < 3))
{
savem = savemean[m_TestMean[j]] - m_Mean[m_TestMean[j]];
savev = saveSTD[m_TestSTD[j]] - m_STD[m_TestSTD[j]];
const double savem = savemean[m_TestMean[j]] - m_Mean[m_TestMean[j]];
const double savev = saveSTD[m_TestSTD[j]] - m_STD[m_TestSTD[j]];
if ((savem < -m_MeanTolerance[m_TestMean[j]]) || (savem > m_MeanTolerance[m_TestMean[j]]))
{
ok = false;
return false;
}
if ((savev < -m_STDTolerance[m_TestSTD[j]]) || (savev > m_STDTolerance[m_TestSTD[j]]))
{
ok = false;
return false;
}
++j;
}

if (ok)
{
return true;
}
else
{
return false;
}
return true;
}

template <typename TInputImage, typename TOutputImage>
Expand Down

0 comments on commit fb07d52

Please sign in to comment.