diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-28 17:54:57 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-28 17:54:57 +0000 |
commit | eb3451793aaf42870e44281708ccac51c010e837 (patch) | |
tree | 51c5f3646653b5153a74a2828b2af20c41cbd8d1 /icu4c/source/i18n/number_patternmodifier.cpp | |
parent | e710c4fbd23e1b7d97da0a88a8499326861ad250 (diff) | |
parent | 8144ba71b4efcfe46cd0e76e85d371bcc7d55567 (diff) | |
download | icu-eb3451793aaf42870e44281708ccac51c010e837.tar.gz |
Snap for 11641499 from 8144ba71b4efcfe46cd0e76e85d371bcc7d55567 to build-tools-release
Change-Id: Ic926bb7ff166e37b678ae2768581ebec18fcea4a
Diffstat (limited to 'icu4c/source/i18n/number_patternmodifier.cpp')
-rw-r--r-- | icu4c/source/i18n/number_patternmodifier.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/icu4c/source/i18n/number_patternmodifier.cpp b/icu4c/source/i18n/number_patternmodifier.cpp index 088a30ecd..6f398c6ac 100644 --- a/icu4c/source/i18n/number_patternmodifier.cpp +++ b/icu4c/source/i18n/number_patternmodifier.cpp @@ -60,6 +60,21 @@ bool MutablePatternModifier::needsPlurals() const { // Silently ignore any error codes. } +AdoptingSignumModifierStore MutablePatternModifier::createImmutableForPlural(StandardPlural::Form plural, UErrorCode& status) { + AdoptingSignumModifierStore pm; + + setNumberProperties(SIGNUM_POS, plural); + pm.adoptModifier(SIGNUM_POS, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG_ZERO, plural); + pm.adoptModifier(SIGNUM_NEG_ZERO, createConstantModifier(status)); + setNumberProperties(SIGNUM_POS_ZERO, plural); + pm.adoptModifier(SIGNUM_POS_ZERO, createConstantModifier(status)); + setNumberProperties(SIGNUM_NEG, plural); + pm.adoptModifier(SIGNUM_NEG, createConstantModifier(status)); + + return pm; +} + ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& status) { // TODO: Move StandardPlural VALUES to standardplural.h static const StandardPlural::Form STANDARD_PLURAL_VALUES[] = { @@ -79,14 +94,7 @@ ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& st if (needsPlurals()) { // Slower path when we require the plural keyword. for (StandardPlural::Form plural : STANDARD_PLURAL_VALUES) { - setNumberProperties(SIGNUM_POS, plural); - pm->adoptModifier(SIGNUM_POS, plural, createConstantModifier(status)); - setNumberProperties(SIGNUM_NEG_ZERO, plural); - pm->adoptModifier(SIGNUM_NEG_ZERO, plural, createConstantModifier(status)); - setNumberProperties(SIGNUM_POS_ZERO, plural); - pm->adoptModifier(SIGNUM_POS_ZERO, plural, createConstantModifier(status)); - setNumberProperties(SIGNUM_NEG, plural); - pm->adoptModifier(SIGNUM_NEG, plural, createConstantModifier(status)); + pm->adoptSignumModifierStore(plural, createImmutableForPlural(plural, status)); } if (U_FAILURE(status)) { delete pm; @@ -95,14 +103,7 @@ ImmutablePatternModifier* MutablePatternModifier::createImmutable(UErrorCode& st return new ImmutablePatternModifier(pm, fRules); // adopts pm } else { // Faster path when plural keyword is not needed. - setNumberProperties(SIGNUM_POS, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(SIGNUM_POS, createConstantModifier(status)); - setNumberProperties(SIGNUM_NEG_ZERO, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(SIGNUM_NEG_ZERO, createConstantModifier(status)); - setNumberProperties(SIGNUM_POS_ZERO, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(SIGNUM_POS_ZERO, createConstantModifier(status)); - setNumberProperties(SIGNUM_NEG, StandardPlural::Form::COUNT); - pm->adoptModifierWithoutPlural(SIGNUM_NEG, createConstantModifier(status)); + pm->adoptSignumModifierStoreNoPlural(createImmutableForPlural(StandardPlural::Form::COUNT, status)); if (U_FAILURE(status)) { delete pm; return nullptr; |