From: Shane F. Carr Date: Wed, 18 Mar 2020 00:30:11 +0000 (-0500) Subject: Rename TempSingleUnit -> SingleUnitImpl X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51bbd9b4763d17bb81e4687747d07fe5c60f9e96;p=icu Rename TempSingleUnit -> SingleUnitImpl --- diff --git a/icu4c/source/i18n/measunit_extra.cpp b/icu4c/source/i18n/measunit_extra.cpp index 186d34777f3..f68e0a46030 100644 --- a/icu4c/source/i18n/measunit_extra.cpp +++ b/icu4c/source/i18n/measunit_extra.cpp @@ -377,7 +377,7 @@ private: return Token(match); } - void nextSingleUnit(TempSingleUnit& result, bool& sawPlus, UErrorCode& status) { + void nextSingleUnit(SingleUnitImpl& result, bool& sawPlus, UErrorCode& status) { sawPlus = false; if (U_FAILURE(status)) { return; @@ -477,7 +477,7 @@ private: int32_t unitNum = 0; while (hasNext()) { bool sawPlus; - TempSingleUnit singleUnit; + SingleUnitImpl singleUnit; nextSingleUnit(singleUnit, sawPlus, status); if (U_FAILURE(status)) { return; @@ -510,15 +510,15 @@ private: int32_t U_CALLCONV compareSingleUnits(const void* /*context*/, const void* left, const void* right) { - auto realLeft = static_cast(left); - auto realRight = static_cast(right); + auto realLeft = static_cast(left); + auto realRight = static_cast(right); return (*realLeft)->compareTo(**realRight); } /** * Generate the identifier string for a single unit in place. */ -void serializeSingle(const TempSingleUnit& singleUnit, bool first, CharString& output, UErrorCode& status) { +void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& output, UErrorCode& status) { if (first && singleUnit.dimensionality < 0) { output.append("one-per-", status); } @@ -598,8 +598,8 @@ void serialize(MeasureUnitImpl& impl, UErrorCode& status) { return; } for (int32_t i = 1; i < impl.units.length(); i++) { - const TempSingleUnit& prev = *impl.units[i-1]; - const TempSingleUnit& curr = *impl.units[i]; + const SingleUnitImpl& prev = *impl.units[i-1]; + const SingleUnitImpl& curr = *impl.units[i]; if (impl.complexity == UMEASURE_UNIT_SEQUENCE) { impl.identifier.append('+', status); serializeSingle(curr, true, impl.identifier, status); @@ -616,9 +616,9 @@ void serialize(MeasureUnitImpl& impl, UErrorCode& status) { } /** @return true if a new item was added */ -bool appendImpl(MeasureUnitImpl& impl, const TempSingleUnit& unit, UErrorCode& status) { +bool appendImpl(MeasureUnitImpl& impl, const SingleUnitImpl& unit, UErrorCode& status) { // Find a similar unit that already exists, to attempt to coalesce - TempSingleUnit* oldUnit = nullptr; + SingleUnitImpl* oldUnit = nullptr; for (int32_t i = 0; i < impl.units.length(); i++) { auto* candidate = impl.units[i]; if (candidate->isCompatibleWith(unit)) { @@ -628,7 +628,7 @@ bool appendImpl(MeasureUnitImpl& impl, const TempSingleUnit& unit, UErrorCode& s if (oldUnit) { oldUnit->dimensionality += unit.dimensionality; } else { - TempSingleUnit* destination = impl.units.emplaceBack(); + SingleUnitImpl* destination = impl.units.emplaceBack(); if (!destination) { status = U_MEMORY_ALLOCATION_ERROR; return false; @@ -641,7 +641,7 @@ bool appendImpl(MeasureUnitImpl& impl, const TempSingleUnit& unit, UErrorCode& s } // namespace -TempSingleUnit TempSingleUnit::forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status) { +SingleUnitImpl SingleUnitImpl::forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status) { MeasureUnitImpl temp; const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(measureUnit, temp, status); if (U_FAILURE(status)) { @@ -657,7 +657,7 @@ TempSingleUnit TempSingleUnit::forMeasureUnit(const MeasureUnit& measureUnit, UE } } -MeasureUnit TempSingleUnit::build(UErrorCode& status) { +MeasureUnit SingleUnitImpl::build(UErrorCode& status) { MeasureUnitImpl temp; temp.append(*this, status); return std::move(temp).build(status); @@ -694,7 +694,7 @@ void MeasureUnitImpl::takeReciprocal(UErrorCode& /*status*/) { } } -bool MeasureUnitImpl::append(const TempSingleUnit& singleUnit, UErrorCode& status) { +bool MeasureUnitImpl::append(const SingleUnitImpl& singleUnit, UErrorCode& status) { identifier.clear(); return appendImpl(*this, singleUnit, status); } @@ -715,21 +715,21 @@ UMeasureUnitComplexity MeasureUnit::getComplexity(UErrorCode& status) const { } UMeasureSIPrefix MeasureUnit::getSIPrefix(UErrorCode& status) const { - return TempSingleUnit::forMeasureUnit(*this, status).siPrefix; + return SingleUnitImpl::forMeasureUnit(*this, status).siPrefix; } MeasureUnit MeasureUnit::withSIPrefix(UMeasureSIPrefix prefix, UErrorCode& status) const { - TempSingleUnit singleUnit = TempSingleUnit::forMeasureUnit(*this, status); + SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status); singleUnit.siPrefix = prefix; return singleUnit.build(status); } int32_t MeasureUnit::getDimensionality(UErrorCode& status) const { - return TempSingleUnit::forMeasureUnit(*this, status).dimensionality; + return SingleUnitImpl::forMeasureUnit(*this, status).dimensionality; } MeasureUnit MeasureUnit::withDimensionality(int32_t dimensionality, UErrorCode& status) const { - TempSingleUnit singleUnit = TempSingleUnit::forMeasureUnit(*this, status); + SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status); singleUnit.dimensionality = dimensionality; return singleUnit.build(status); } diff --git a/icu4c/source/i18n/measunit_impl.h b/icu4c/source/i18n/measunit_impl.h index ffcd0581ce1..dd5d70902ee 100644 --- a/icu4c/source/i18n/measunit_impl.h +++ b/icu4c/source/i18n/measunit_impl.h @@ -15,18 +15,18 @@ U_NAMESPACE_BEGIN -struct TempSingleUnit : public UMemory { +struct SingleUnitImpl : public UMemory { /** * Gets a single unit from the MeasureUnit. If there are multiple single units, sets an error * code and return the base dimensionless unit. Parses if necessary. */ - static TempSingleUnit forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status); + static SingleUnitImpl forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status); - /** Transform this TemplSingleUnit into a MeasureUnit, simplifying if possible. */ + /** Transform this SingleUnitImpl into a MeasureUnit, simplifying if possible. */ MeasureUnit build(UErrorCode& status); - /** Compare this TempSingleUnit to another TempSingleUnit. */ - int32_t compareTo(const TempSingleUnit& other) const { + /** Compare this SingleUnitImpl to another SingleUnitImpl. */ + int32_t compareTo(const SingleUnitImpl& other) const { if (dimensionality < 0 && other.dimensionality > 0) { // Positive dimensions first return 1; @@ -46,12 +46,12 @@ struct TempSingleUnit : public UMemory { } /** - * Return whether this TempSingleUnit is compatible with another for the purpose of coalescing. + * Return whether this SingleUnitImpl is compatible with another for the purpose of coalescing. * * Units with the same base unit and SI prefix should match, except that they must also have * the same dimensionality sign, such that we don't merge numerator and denominator. */ - bool isCompatibleWith(const TempSingleUnit& other) const { + bool isCompatibleWith(const SingleUnitImpl& other) const { return (compareTo(other) == 0); } @@ -138,7 +138,7 @@ struct MeasureUnitImpl : public UMemory { void takeReciprocal(UErrorCode& status); /** Mutates this MeasureUnitImpl to append a single unit. */ - bool append(const TempSingleUnit& singleUnit, UErrorCode& status); + bool append(const SingleUnitImpl& singleUnit, UErrorCode& status); /** The complexity, either SINGLE, COMPOUND, or SEQUENCE. */ UMeasureUnitComplexity complexity = UMEASURE_UNIT_SINGLE; @@ -147,7 +147,7 @@ struct MeasureUnitImpl : public UMemory { * The list of simple units. These may be summed or multiplied, based on the value of the * complexity field. */ - MaybeStackVector units; + MaybeStackVector units; /** * The full unit identifier. Owned by the MeasureUnitImpl. Empty if not computed. diff --git a/icu4c/source/i18n/number_skeletons.cpp b/icu4c/source/i18n/number_skeletons.cpp index a202bdf14e8..6bd1e89812f 100644 --- a/icu4c/source/i18n/number_skeletons.cpp +++ b/icu4c/source/i18n/number_skeletons.cpp @@ -1051,7 +1051,7 @@ void blueprint_helpers::parseIdentifierUnitOption(const StringSegment& segment, // TODO(ICU-20941): Clean this up. for (int32_t i = 0; i < fullUnit.units.length(); i++) { - TempSingleUnit* subUnit = fullUnit.units[i]; + SingleUnitImpl* subUnit = fullUnit.units[i]; if (subUnit->dimensionality > 0) { macros.unit = macros.unit.product(subUnit->build(status), status); } else {