From cab6c1626b7a33037ace0aaf324644be4162b8b6 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Thu, 23 Aug 2018 10:39:20 +0100 Subject: [PATCH] Improve readability of loop stop condition --- Framework/Geometry/src/Crystal/IndexingUtils.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Framework/Geometry/src/Crystal/IndexingUtils.cpp b/Framework/Geometry/src/Crystal/IndexingUtils.cpp index 78a13915e40..326bba17c43 100644 --- a/Framework/Geometry/src/Crystal/IndexingUtils.cpp +++ b/Framework/Geometry/src/Crystal/IndexingUtils.cpp @@ -1473,9 +1473,7 @@ double IndexingUtils::GetFirstMaxIndex(const double magnitude_fft[], size_t N, if (found_max) { double sum = 0; double w_sum = 0; - // only include single extra index if we're too near the end - const size_t last_index = i < N - 2 ? i + 2 : i + 1; - for (size_t j = i - 2; j <= last_index; j++) { + for (size_t j = i - 2; j < std::min(N, i + 3); j++) { sum += static_cast<double>(j) * magnitude_fft[j]; w_sum += magnitude_fft[j]; } -- GitLab