mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
fix warning in UnitsRouter#route function
This commit is contained in:
parent
6ffa7ae6e6
commit
6a26ea440a
1 changed files with 4 additions and 5 deletions
|
@ -48,17 +48,16 @@ UnitsRouter::UnitsRouter(MeasureUnit inputUnit, StringPiece region, StringPiece
|
|||
|
||||
MaybeStackVector<Measure> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue