From 6a26ea440aacb3e1823d581072a4d4d13d2d651a Mon Sep 17 00:00:00 2001 From: younies Date: Sun, 14 Jun 2020 11:33:33 +0200 Subject: [PATCH] fix warning in UnitsRouter#route function --- icu4c/source/i18n/unitsrouter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/icu4c/source/i18n/unitsrouter.cpp b/icu4c/source/i18n/unitsrouter.cpp index 1cfa2b971d4..ca5f8cbf724 100644 --- a/icu4c/source/i18n/unitsrouter.cpp +++ b/icu4c/source/i18n/unitsrouter.cpp @@ -48,17 +48,16 @@ UnitsRouter::UnitsRouter(MeasureUnit inputUnit, StringPiece region, StringPiece MaybeStackVector UnitsRouter::route(double quantity, UErrorCode &status) { for (int i = 0, n = converterPreferences_.length(); i < n; i++) { - const auto &converterPreference = *converterPreferences_[i]; - // In case of the last converter, the conversion will performed even the value is less than the - // limit. - if (i == n - 1) { return converterPreference.converter.convert(quantity, status); } - if (converterPreference.converter.greaterThanOrEqual(quantity, converterPreference.limit)) { return converterPreference.converter.convert(quantity, status); } } + + // In case of the `quantity` does not fit in any converter limit, use the last converter. + const auto &lastConverter = (*converterPreferences_[converterPreferences_.length() - 1]).converter; + return lastConverter.convert(quantity, status); } U_NAMESPACE_END