]> granicus.if.org Git - icu/commitdiff
fix simplify function
authoryounies <younies@chromium.org>
Sat, 13 Jun 2020 16:14:51 +0000 (18:14 +0200)
committeryounies <younies@chromium.org>
Sat, 13 Jun 2020 16:14:51 +0000 (18:14 +0200)
icu4c/source/i18n/measunit_extra.cpp

index d6576e34110f316efdffbabe64094a9b0df3b0b0..982a095d433e5a2bf43a4b822933bf2a68dbcf0c 100644 (file)
@@ -769,19 +769,6 @@ MeasureUnit MeasureUnit::product(const MeasureUnit& other, UErrorCode& status) c
     return std::move(impl).build(status);
 }
 
-
-/**
- * Returns the sign of the dimensionality.
- * 
- * NOTE:
- *      it returns `0` when the dimensionality is zero. 
- */ 
-int32_t dimensionSign(int32_t dimension) {
-    if (dimension == 0) return 0;
-    if (dimension > 0) return 1;
-    return -1;
-}
-
 /**
  * Searches the `simplifiedUnits` for a unit with the same base identifier in the `newUnit`, for example
  * `meter` and `meter` or `millimeter` and `centimeter`.
@@ -796,8 +783,8 @@ bool findAndSet(MaybeStackVector<MeasureUnit> &simplifiedUnits, const MeasureUni
         if (simplifiedUnitImpl.identifier == newUnitImpl.identifier) {
             int32_t newDimensionality = simplifiedUnitImpl.dimensionality + newUnitImpl.dimensionality;
             UMeasureSIPrefix newSIprefix = static_cast<UMeasureSIPrefix>(
-                simplifiedUnitImpl.siPrefix * dimensionSign(simplifiedUnitImpl.dimensionality) +
-                newUnitImpl.siPrefix * dimensionSign(newUnitImpl.dimensionality));
+                simplifiedUnitImpl.siPrefix * simplifiedUnitImpl.dimensionality +
+                newUnitImpl.siPrefix * newUnitImpl.dimensionality);
 
             auto &simplifiedUnit = *simplifiedUnits[i];
             simplifiedUnit = simplifiedUnit.withDimensionality(newDimensionality, status);