mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-11 08:01:32 +00:00
ICU-22950 Do not initialize currency redundantly
resolveCurrency() slows down simple number formatting requests like: for (int i = 0; i < 9999; i++) u_snprintf_u(buff, 100, u"%d", i); Since we don't use currency here, we can skip its initialization.
This commit is contained in:
parent
bbaa68419b
commit
624a26030b
1 changed files with 6 additions and 3 deletions
|
@ -74,9 +74,11 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
|
|||
!properties.currencyPluralInfo.fPtr.isNull() ||
|
||||
!properties.currencyUsage.isNull() ||
|
||||
warehouse.affixProvider.get().hasCurrencySign());
|
||||
CurrencyUnit currency = resolveCurrency(properties, locale, status);
|
||||
UCurrencyUsage currencyUsage = properties.currencyUsage.getOrDefault(UCURR_USAGE_STANDARD);
|
||||
CurrencyUnit currency;
|
||||
UCurrencyUsage currencyUsage;
|
||||
if (useCurrency) {
|
||||
currency = resolveCurrency(properties, locale, status);
|
||||
currencyUsage = properties.currencyUsage.getOrDefault(UCURR_USAGE_STANDARD);
|
||||
// NOTE: Slicing is OK.
|
||||
macros.unit = currency; // NOLINT
|
||||
}
|
||||
|
@ -129,6 +131,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
|
|||
}
|
||||
Precision precision;
|
||||
if (!properties.currencyUsage.isNull()) {
|
||||
U_ASSERT(useCurrency);
|
||||
precision = Precision::constructCurrency(currencyUsage).withCurrency(currency);
|
||||
} else if (roundingIncrement != 0.0) {
|
||||
if (PatternStringUtils::ignoreRoundingIncrement(roundingIncrement, maxFrac)) {
|
||||
|
@ -276,7 +279,7 @@ MacroProps NumberPropertyMapper::oldToNew(const DecimalFormatProperties& propert
|
|||
exportedProperties->maximumIntegerDigits = maxInt == -1 ? INT32_MAX : maxInt;
|
||||
|
||||
Precision rounding_;
|
||||
if (precision.fType == Precision::PrecisionType::RND_CURRENCY) {
|
||||
if (useCurrency && precision.fType == Precision::PrecisionType::RND_CURRENCY) {
|
||||
rounding_ = precision.withCurrency(currency, status);
|
||||
} else {
|
||||
rounding_ = precision;
|
||||
|
|
Loading…
Add table
Reference in a new issue