ICU-20394 Changing DecimalFormatFields to not allocate as many objects

This commit is contained in:
Shane Carr 2019-08-08 17:41:55 -07:00 committed by Shane F. Carr
parent 513b0c20b0
commit f4fc9d06c2
3 changed files with 186 additions and 190 deletions

View file

@ -30,9 +30,9 @@ CompactDecimalFormat::CompactDecimalFormat(const Locale& inLocale, UNumberCompac
: DecimalFormat(new DecimalFormatSymbols(inLocale, status), status) {
if (U_FAILURE(status)) return;
// Minimal properties: let the non-shim code path do most of the logic for us.
fields->properties->compactStyle = style;
fields->properties->groupingSize = -2; // do not forward grouping information
fields->properties->minimumGroupingDigits = 2;
fields->properties.compactStyle = style;
fields->properties.groupingSize = -2; // do not forward grouping information
fields->properties.minimumGroupingDigits = 2;
touch(status);
}

View file

@ -95,7 +95,7 @@ DecimalFormat::DecimalFormat(const UnicodeString& pattern, DecimalFormatSymbols*
new CurrencyPluralInfo(fields->symbols->getLocale(), status),
status);
if (U_FAILURE(status)) { return; }
fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan());
fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan());
}
touch(status);
}
@ -111,21 +111,14 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status);
fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status);
fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status);
if (adoptedSymbols.isNull()) {
fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(status), status);
} else {
fields->symbols.adoptInsteadAndCheckErrorCode(adoptedSymbols.orphan(), status);
}
// In order to simplify error handling logic in the various getters/setters/etc, we do not allow
// any partially populated DecimalFormatFields object. We must have a fully complete fields object
// or else we set it to nullptr.
if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) {
if (U_FAILURE(status)) {
delete fields;
fields = nullptr;
status = U_MEMORY_ALLOCATION_ERROR;
}
}
@ -133,8 +126,8 @@ DecimalFormat::DecimalFormat(const DecimalFormatSymbols* symbolsToAdopt, UErrorC
void DecimalFormat::setParseAllInput(UNumberFormatAttributeValue value) {
if (fields == nullptr) { return; }
if (value == fields->properties->parseAllInput) { return; }
fields->properties->parseAllInput = value;
if (value == fields->properties.parseAllInput) { return; }
fields->properties.parseAllInput = value;
}
#endif
@ -379,9 +372,9 @@ void DecimalFormat::setGroupingUsed(UBool enabled) {
if (fields == nullptr) {
return;
}
if (UBOOL_TO_BOOL(enabled) == fields->properties->groupingUsed) { return; }
if (UBOOL_TO_BOOL(enabled) == fields->properties.groupingUsed) { return; }
NumberFormat::setGroupingUsed(enabled); // to set field for compatibility
fields->properties->groupingUsed = enabled;
fields->properties.groupingUsed = enabled;
touchNoError();
}
@ -389,9 +382,9 @@ void DecimalFormat::setParseIntegerOnly(UBool value) {
if (fields == nullptr) {
return;
}
if (UBOOL_TO_BOOL(value) == fields->properties->parseIntegerOnly) { return; }
if (UBOOL_TO_BOOL(value) == fields->properties.parseIntegerOnly) { return; }
NumberFormat::setParseIntegerOnly(value); // to set field for compatibility
fields->properties->parseIntegerOnly = value;
fields->properties.parseIntegerOnly = value;
touchNoError();
}
@ -400,9 +393,9 @@ void DecimalFormat::setLenient(UBool enable) {
return;
}
ParseMode mode = enable ? PARSE_MODE_LENIENT : PARSE_MODE_STRICT;
if (!fields->properties->parseMode.isNull() && mode == fields->properties->parseMode.getNoError()) { return; }
if (!fields->properties.parseMode.isNull() && mode == fields->properties.parseMode.getNoError()) { return; }
NumberFormat::setLenient(enable); // to set field for compatibility
fields->properties->parseMode = mode;
fields->properties.parseMode = mode;
touchNoError();
}
@ -441,19 +434,16 @@ DecimalFormat::DecimalFormat(const DecimalFormat& source) : NumberFormat(source)
// Note: it is not safe to copy fields->formatter or fWarehouse directly because fields->formatter might have
// dangling pointers to fields inside fWarehouse. The safe thing is to re-construct fields->formatter from
// the property bag, despite being somewhat slower.
fields = new DecimalFormatFields();
fields = new DecimalFormatFields(source.fields->properties);
if (fields == nullptr) {
return; // no way to report an error.
}
UErrorCode status = U_ZERO_ERROR;
fields->formatter.adoptInsteadAndCheckErrorCode(new LocalizedNumberFormatter(), status);
fields->properties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(*source.fields->properties), status);
fields->symbols.adoptInsteadAndCheckErrorCode(new DecimalFormatSymbols(*source.fields->symbols), status);
fields->exportedProperties.adoptInsteadAndCheckErrorCode(new DecimalFormatProperties(), status);
// In order to simplify error handling logic in the various getters/setters/etc, we do not allow
// any partially populated DecimalFormatFields object. We must have a fully complete fields object
// or else we set it to nullptr.
if (fields->formatter.isNull() || fields->properties.isNull() || fields->exportedProperties.isNull() || fields->symbols.isNull()) {
if (U_FAILURE(status)) {
delete fields;
fields = nullptr;
return;
@ -470,8 +460,8 @@ DecimalFormat& DecimalFormat::operator=(const DecimalFormat& rhs) {
if (fields == nullptr || rhs.fields == nullptr) {
return *this; // unfortunately, no way to report an error.
}
*fields->properties = *rhs.fields->properties;
fields->exportedProperties->clear();
fields->properties = rhs.fields->properties;
fields->exportedProperties.clear();
UErrorCode status = U_ZERO_ERROR;
LocalPointer<DecimalFormatSymbols> dfs(new DecimalFormatSymbols(*rhs.fields->symbols), status);
if (U_FAILURE(status)) {
@ -517,7 +507,7 @@ UBool DecimalFormat::operator==(const Format& other) const {
if (fields == nullptr || otherDF->fields == nullptr) {
return false;
}
return *fields->properties == *otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols;
return fields->properties == otherDF->fields->properties && *fields->symbols == *otherDF->fields->symbols;
}
UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const {
@ -529,7 +519,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie
return appendTo;
}
UErrorCode localStatus = U_ZERO_ERROR;
FormattedNumber output = fields->formatter->formatDouble(number, localStatus);
FormattedNumber output = fields->formatter.formatDouble(number, localStatus);
fieldPositionHelper(output, pos, appendTo.length(), localStatus);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, localStatus);
@ -550,7 +540,7 @@ UnicodeString& DecimalFormat::format(double number, UnicodeString& appendTo, Fie
if (pos.getField() == FieldPosition::DONT_CARE && fastFormatDouble(number, appendTo)) {
return appendTo;
}
FormattedNumber output = fields->formatter->formatDouble(number, status);
FormattedNumber output = fields->formatter.formatDouble(number, status);
fieldPositionHelper(output, pos, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -572,7 +562,7 @@ DecimalFormat::format(double number, UnicodeString& appendTo, FieldPositionItera
if (posIter == nullptr && fastFormatDouble(number, appendTo)) {
return appendTo;
}
FormattedNumber output = fields->formatter->formatDouble(number, status);
FormattedNumber output = fields->formatter.formatDouble(number, status);
fieldPositionIteratorHelper(output, posIter, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -603,7 +593,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi
return appendTo;
}
UErrorCode localStatus = U_ZERO_ERROR;
FormattedNumber output = fields->formatter->formatInt(number, localStatus);
FormattedNumber output = fields->formatter.formatInt(number, localStatus);
fieldPositionHelper(output, pos, appendTo.length(), localStatus);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, localStatus);
@ -624,7 +614,7 @@ UnicodeString& DecimalFormat::format(int64_t number, UnicodeString& appendTo, Fi
if (pos.getField() == FieldPosition::DONT_CARE && fastFormatInt64(number, appendTo)) {
return appendTo;
}
FormattedNumber output = fields->formatter->formatInt(number, status);
FormattedNumber output = fields->formatter.formatInt(number, status);
fieldPositionHelper(output, pos, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -646,7 +636,7 @@ DecimalFormat::format(int64_t number, UnicodeString& appendTo, FieldPositionIter
if (posIter == nullptr && fastFormatInt64(number, appendTo)) {
return appendTo;
}
FormattedNumber output = fields->formatter->formatInt(number, status);
FormattedNumber output = fields->formatter.formatInt(number, status);
fieldPositionIteratorHelper(output, posIter, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -665,7 +655,7 @@ DecimalFormat::format(StringPiece number, UnicodeString& appendTo, FieldPosition
appendTo.setToBogus();
return appendTo;
}
FormattedNumber output = fields->formatter->formatDecimal(number, status);
FormattedNumber output = fields->formatter.formatDecimal(number, status);
fieldPositionIteratorHelper(output, posIter, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -683,7 +673,7 @@ UnicodeString& DecimalFormat::format(const DecimalQuantity& number, UnicodeStrin
appendTo.setToBogus();
return appendTo;
}
FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status);
FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status);
fieldPositionIteratorHelper(output, posIter, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -702,7 +692,7 @@ DecimalFormat::format(const DecimalQuantity& number, UnicodeString& appendTo, Fi
appendTo.setToBogus();
return appendTo;
}
FormattedNumber output = fields->formatter->formatDecimalQuantity(number, status);
FormattedNumber output = fields->formatter.formatDecimalQuantity(number, status);
fieldPositionHelper(output, pos, appendTo.length(), status);
auto appendable = UnicodeStringAppendable(appendTo);
output.appendTo(appendable, status);
@ -823,7 +813,7 @@ const CurrencyPluralInfo* DecimalFormat::getCurrencyPluralInfo(void) const {
if (fields == nullptr) {
return nullptr;
}
return fields->properties->currencyPluralInfo.fPtr.getAlias();
return fields->properties.currencyPluralInfo.fPtr.getAlias();
}
void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) {
@ -833,7 +823,7 @@ void DecimalFormat::adoptCurrencyPluralInfo(CurrencyPluralInfo* toAdopt) {
if (fields == nullptr) {
return;
}
fields->properties->currencyPluralInfo.fPtr.adoptInstead(cpi.orphan());
fields->properties.currencyPluralInfo.fPtr.adoptInstead(cpi.orphan());
touchNoError();
}
@ -841,11 +831,11 @@ void DecimalFormat::setCurrencyPluralInfo(const CurrencyPluralInfo& info) {
if (fields == nullptr) {
return;
}
if (fields->properties->currencyPluralInfo.fPtr.isNull()) {
if (fields->properties.currencyPluralInfo.fPtr.isNull()) {
// Note: clone() can fail with OOM error, but we have no way to report it. :(
fields->properties->currencyPluralInfo.fPtr.adoptInstead(info.clone());
fields->properties.currencyPluralInfo.fPtr.adoptInstead(info.clone());
} else {
*fields->properties->currencyPluralInfo.fPtr = info; // copy-assignment operator
*fields->properties.currencyPluralInfo.fPtr = info; // copy-assignment operator
}
touchNoError();
}
@ -856,7 +846,7 @@ UnicodeString& DecimalFormat::getPositivePrefix(UnicodeString& result) const {
return result;
}
UErrorCode status = U_ZERO_ERROR;
fields->formatter->getAffixImpl(true, false, result, status);
fields->formatter.getAffixImpl(true, false, result, status);
if (U_FAILURE(status)) { result.setToBogus(); }
return result;
}
@ -865,8 +855,8 @@ void DecimalFormat::setPositivePrefix(const UnicodeString& newValue) {
if (fields == nullptr) {
return;
}
if (newValue == fields->properties->positivePrefix) { return; }
fields->properties->positivePrefix = newValue;
if (newValue == fields->properties.positivePrefix) { return; }
fields->properties.positivePrefix = newValue;
touchNoError();
}
@ -876,7 +866,7 @@ UnicodeString& DecimalFormat::getNegativePrefix(UnicodeString& result) const {
return result;
}
UErrorCode status = U_ZERO_ERROR;
fields->formatter->getAffixImpl(true, true, result, status);
fields->formatter.getAffixImpl(true, true, result, status);
if (U_FAILURE(status)) { result.setToBogus(); }
return result;
}
@ -885,8 +875,8 @@ void DecimalFormat::setNegativePrefix(const UnicodeString& newValue) {
if (fields == nullptr) {
return;
}
if (newValue == fields->properties->negativePrefix) { return; }
fields->properties->negativePrefix = newValue;
if (newValue == fields->properties.negativePrefix) { return; }
fields->properties.negativePrefix = newValue;
touchNoError();
}
@ -896,7 +886,7 @@ UnicodeString& DecimalFormat::getPositiveSuffix(UnicodeString& result) const {
return result;
}
UErrorCode status = U_ZERO_ERROR;
fields->formatter->getAffixImpl(false, false, result, status);
fields->formatter.getAffixImpl(false, false, result, status);
if (U_FAILURE(status)) { result.setToBogus(); }
return result;
}
@ -905,8 +895,8 @@ void DecimalFormat::setPositiveSuffix(const UnicodeString& newValue) {
if (fields == nullptr) {
return;
}
if (newValue == fields->properties->positiveSuffix) { return; }
fields->properties->positiveSuffix = newValue;
if (newValue == fields->properties.positiveSuffix) { return; }
fields->properties.positiveSuffix = newValue;
touchNoError();
}
@ -916,7 +906,7 @@ UnicodeString& DecimalFormat::getNegativeSuffix(UnicodeString& result) const {
return result;
}
UErrorCode status = U_ZERO_ERROR;
fields->formatter->getAffixImpl(false, true, result, status);
fields->formatter.getAffixImpl(false, true, result, status);
if (U_FAILURE(status)) { result.setToBogus(); }
return result;
}
@ -925,8 +915,8 @@ void DecimalFormat::setNegativeSuffix(const UnicodeString& newValue) {
if (fields == nullptr) {
return;
}
if (newValue == fields->properties->negativeSuffix) { return; }
fields->properties->negativeSuffix = newValue;
if (newValue == fields->properties.negativeSuffix) { return; }
fields->properties.negativeSuffix = newValue;
touchNoError();
}
@ -935,13 +925,13 @@ UBool DecimalFormat::isSignAlwaysShown() const {
if (fields == nullptr) {
return DecimalFormatProperties::getDefault().signAlwaysShown;
}
return fields->properties->signAlwaysShown;
return fields->properties.signAlwaysShown;
}
void DecimalFormat::setSignAlwaysShown(UBool value) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(value) == fields->properties->signAlwaysShown) { return; }
fields->properties->signAlwaysShown = value;
if (UBOOL_TO_BOOL(value) == fields->properties.signAlwaysShown) { return; }
fields->properties.signAlwaysShown = value;
touchNoError();
}
@ -952,7 +942,7 @@ int32_t DecimalFormat::getMultiplier(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
dfp = &(DecimalFormatProperties::getDefault());
} else {
dfp = fields->properties.getAlias();
dfp = &fields->properties;
}
if (dfp->multiplier != 1) {
return dfp->multiplier;
@ -984,11 +974,11 @@ void DecimalFormat::setMultiplier(int32_t multiplier) {
value = temp;
}
if (delta != -1) {
fields->properties->magnitudeMultiplier = delta;
fields->properties->multiplier = 1;
fields->properties.magnitudeMultiplier = delta;
fields->properties.multiplier = 1;
} else {
fields->properties->magnitudeMultiplier = 0;
fields->properties->multiplier = multiplier;
fields->properties.magnitudeMultiplier = 0;
fields->properties.multiplier = multiplier;
}
touchNoError();
}
@ -999,13 +989,13 @@ int32_t DecimalFormat::getMultiplierScale() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().multiplierScale;
}
return fields->properties->multiplierScale;
return fields->properties.multiplierScale;
}
void DecimalFormat::setMultiplierScale(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->multiplierScale) { return; }
fields->properties->multiplierScale = newValue;
if (newValue == fields->properties.multiplierScale) { return; }
fields->properties.multiplierScale = newValue;
touchNoError();
}
@ -1015,13 +1005,13 @@ double DecimalFormat::getRoundingIncrement(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().roundingIncrement;
}
return fields->exportedProperties->roundingIncrement;
return fields->exportedProperties.roundingIncrement;
}
void DecimalFormat::setRoundingIncrement(double newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->roundingIncrement) { return; }
fields->properties->roundingIncrement = newValue;
if (newValue == fields->properties.roundingIncrement) { return; }
fields->properties.roundingIncrement = newValue;
touchNoError();
}
@ -1032,17 +1022,17 @@ ERoundingMode DecimalFormat::getRoundingMode(void) const {
return static_cast<ERoundingMode>(DecimalFormatProperties::getDefault().roundingMode.getNoError());
}
// UNumberFormatRoundingMode and ERoundingMode have the same values.
return static_cast<ERoundingMode>(fields->exportedProperties->roundingMode.getNoError());
return static_cast<ERoundingMode>(fields->exportedProperties.roundingMode.getNoError());
}
void DecimalFormat::setRoundingMode(ERoundingMode roundingMode) {
if (fields == nullptr) { return; }
auto uRoundingMode = static_cast<UNumberFormatRoundingMode>(roundingMode);
if (!fields->properties->roundingMode.isNull() && uRoundingMode == fields->properties->roundingMode.getNoError()) {
if (!fields->properties.roundingMode.isNull() && uRoundingMode == fields->properties.roundingMode.getNoError()) {
return;
}
NumberFormat::setMaximumIntegerDigits(roundingMode); // to set field for compatibility
fields->properties->roundingMode = uRoundingMode;
fields->properties.roundingMode = uRoundingMode;
touchNoError();
}
@ -1052,52 +1042,52 @@ int32_t DecimalFormat::getFormatWidth(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().formatWidth;
}
return fields->properties->formatWidth;
return fields->properties.formatWidth;
}
void DecimalFormat::setFormatWidth(int32_t width) {
if (fields == nullptr) { return; }
if (width == fields->properties->formatWidth) { return; }
fields->properties->formatWidth = width;
if (width == fields->properties.formatWidth) { return; }
fields->properties.formatWidth = width;
touchNoError();
}
UnicodeString DecimalFormat::getPadCharacterString() const {
if (fields == nullptr || fields->properties->padString.isBogus()) {
if (fields == nullptr || fields->properties.padString.isBogus()) {
// Readonly-alias the static string kFallbackPaddingString
return {TRUE, kFallbackPaddingString, -1};
} else {
return fields->properties->padString;
return fields->properties.padString;
}
}
void DecimalFormat::setPadCharacter(const UnicodeString& padChar) {
if (fields == nullptr) { return; }
if (padChar == fields->properties->padString) { return; }
if (padChar == fields->properties.padString) { return; }
if (padChar.length() > 0) {
fields->properties->padString = UnicodeString(padChar.char32At(0));
fields->properties.padString = UnicodeString(padChar.char32At(0));
} else {
fields->properties->padString.setToBogus();
fields->properties.padString.setToBogus();
}
touchNoError();
}
EPadPosition DecimalFormat::getPadPosition(void) const {
if (fields == nullptr || fields->properties->padPosition.isNull()) {
if (fields == nullptr || fields->properties.padPosition.isNull()) {
return EPadPosition::kPadBeforePrefix;
} else {
// UNumberFormatPadPosition and EPadPosition have the same values.
return static_cast<EPadPosition>(fields->properties->padPosition.getNoError());
return static_cast<EPadPosition>(fields->properties.padPosition.getNoError());
}
}
void DecimalFormat::setPadPosition(EPadPosition padPos) {
if (fields == nullptr) { return; }
auto uPadPos = static_cast<UNumberFormatPadPosition>(padPos);
if (!fields->properties->padPosition.isNull() && uPadPos == fields->properties->padPosition.getNoError()) {
if (!fields->properties.padPosition.isNull() && uPadPos == fields->properties.padPosition.getNoError()) {
return;
}
fields->properties->padPosition = uPadPos;
fields->properties.padPosition = uPadPos;
touchNoError();
}
@ -1107,17 +1097,17 @@ UBool DecimalFormat::isScientificNotation(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return (DecimalFormatProperties::getDefault().minimumExponentDigits != -1);
}
return (fields->properties->minimumExponentDigits != -1);
return (fields->properties.minimumExponentDigits != -1);
}
void DecimalFormat::setScientificNotation(UBool useScientific) {
if (fields == nullptr) { return; }
int32_t minExp = useScientific ? 1 : -1;
if (fields->properties->minimumExponentDigits == minExp) { return; }
if (fields->properties.minimumExponentDigits == minExp) { return; }
if (useScientific) {
fields->properties->minimumExponentDigits = 1;
fields->properties.minimumExponentDigits = 1;
} else {
fields->properties->minimumExponentDigits = -1;
fields->properties.minimumExponentDigits = -1;
}
touchNoError();
}
@ -1128,13 +1118,13 @@ int8_t DecimalFormat::getMinimumExponentDigits(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return static_cast<int8_t>(DecimalFormatProperties::getDefault().minimumExponentDigits);
}
return static_cast<int8_t>(fields->properties->minimumExponentDigits);
return static_cast<int8_t>(fields->properties.minimumExponentDigits);
}
void DecimalFormat::setMinimumExponentDigits(int8_t minExpDig) {
if (fields == nullptr) { return; }
if (minExpDig == fields->properties->minimumExponentDigits) { return; }
fields->properties->minimumExponentDigits = minExpDig;
if (minExpDig == fields->properties.minimumExponentDigits) { return; }
fields->properties.minimumExponentDigits = minExpDig;
touchNoError();
}
@ -1144,13 +1134,13 @@ UBool DecimalFormat::isExponentSignAlwaysShown(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().exponentSignAlwaysShown;
}
return fields->properties->exponentSignAlwaysShown;
return fields->properties.exponentSignAlwaysShown;
}
void DecimalFormat::setExponentSignAlwaysShown(UBool expSignAlways) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(expSignAlways) == fields->properties->exponentSignAlwaysShown) { return; }
fields->properties->exponentSignAlwaysShown = expSignAlways;
if (UBOOL_TO_BOOL(expSignAlways) == fields->properties.exponentSignAlwaysShown) { return; }
fields->properties.exponentSignAlwaysShown = expSignAlways;
touchNoError();
}
@ -1161,7 +1151,7 @@ int32_t DecimalFormat::getGroupingSize(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
groupingSize = DecimalFormatProperties::getDefault().groupingSize;
} else {
groupingSize = fields->properties->groupingSize;
groupingSize = fields->properties.groupingSize;
}
if (groupingSize < 0) {
return 0;
@ -1171,8 +1161,8 @@ int32_t DecimalFormat::getGroupingSize(void) const {
void DecimalFormat::setGroupingSize(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->groupingSize) { return; }
fields->properties->groupingSize = newValue;
if (newValue == fields->properties.groupingSize) { return; }
fields->properties.groupingSize = newValue;
touchNoError();
}
@ -1183,7 +1173,7 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
grouping2 = DecimalFormatProperties::getDefault().secondaryGroupingSize;
} else {
grouping2 = fields->properties->secondaryGroupingSize;
grouping2 = fields->properties.secondaryGroupingSize;
}
if (grouping2 < 0) {
return 0;
@ -1193,8 +1183,8 @@ int32_t DecimalFormat::getSecondaryGroupingSize(void) const {
void DecimalFormat::setSecondaryGroupingSize(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->secondaryGroupingSize) { return; }
fields->properties->secondaryGroupingSize = newValue;
if (newValue == fields->properties.secondaryGroupingSize) { return; }
fields->properties.secondaryGroupingSize = newValue;
touchNoError();
}
@ -1204,13 +1194,13 @@ int32_t DecimalFormat::getMinimumGroupingDigits() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().minimumGroupingDigits;
}
return fields->properties->minimumGroupingDigits;
return fields->properties.minimumGroupingDigits;
}
void DecimalFormat::setMinimumGroupingDigits(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->minimumGroupingDigits) { return; }
fields->properties->minimumGroupingDigits = newValue;
if (newValue == fields->properties.minimumGroupingDigits) { return; }
fields->properties.minimumGroupingDigits = newValue;
touchNoError();
}
@ -1220,13 +1210,13 @@ UBool DecimalFormat::isDecimalSeparatorAlwaysShown(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().decimalSeparatorAlwaysShown;
}
return fields->properties->decimalSeparatorAlwaysShown;
return fields->properties.decimalSeparatorAlwaysShown;
}
void DecimalFormat::setDecimalSeparatorAlwaysShown(UBool newValue) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalSeparatorAlwaysShown) { return; }
fields->properties->decimalSeparatorAlwaysShown = newValue;
if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalSeparatorAlwaysShown) { return; }
fields->properties.decimalSeparatorAlwaysShown = newValue;
touchNoError();
}
@ -1236,13 +1226,13 @@ UBool DecimalFormat::isDecimalPatternMatchRequired(void) const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().decimalPatternMatchRequired;
}
return fields->properties->decimalPatternMatchRequired;
return fields->properties.decimalPatternMatchRequired;
}
void DecimalFormat::setDecimalPatternMatchRequired(UBool newValue) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(newValue) == fields->properties->decimalPatternMatchRequired) { return; }
fields->properties->decimalPatternMatchRequired = newValue;
if (UBOOL_TO_BOOL(newValue) == fields->properties.decimalPatternMatchRequired) { return; }
fields->properties.decimalPatternMatchRequired = newValue;
touchNoError();
}
@ -1252,13 +1242,13 @@ UBool DecimalFormat::isParseNoExponent() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().parseNoExponent;
}
return fields->properties->parseNoExponent;
return fields->properties.parseNoExponent;
}
void DecimalFormat::setParseNoExponent(UBool value) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(value) == fields->properties->parseNoExponent) { return; }
fields->properties->parseNoExponent = value;
if (UBOOL_TO_BOOL(value) == fields->properties.parseNoExponent) { return; }
fields->properties.parseNoExponent = value;
touchNoError();
}
@ -1268,13 +1258,13 @@ UBool DecimalFormat::isParseCaseSensitive() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().parseCaseSensitive;
}
return fields->properties->parseCaseSensitive;
return fields->properties.parseCaseSensitive;
}
void DecimalFormat::setParseCaseSensitive(UBool value) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(value) == fields->properties->parseCaseSensitive) { return; }
fields->properties->parseCaseSensitive = value;
if (UBOOL_TO_BOOL(value) == fields->properties.parseCaseSensitive) { return; }
fields->properties.parseCaseSensitive = value;
touchNoError();
}
@ -1284,13 +1274,13 @@ UBool DecimalFormat::isFormatFailIfMoreThanMaxDigits() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().formatFailIfMoreThanMaxDigits;
}
return fields->properties->formatFailIfMoreThanMaxDigits;
return fields->properties.formatFailIfMoreThanMaxDigits;
}
void DecimalFormat::setFormatFailIfMoreThanMaxDigits(UBool value) {
if (fields == nullptr) { return; }
if (UBOOL_TO_BOOL(value) == fields->properties->formatFailIfMoreThanMaxDigits) { return; }
fields->properties->formatFailIfMoreThanMaxDigits = value;
if (UBOOL_TO_BOOL(value) == fields->properties.formatFailIfMoreThanMaxDigits) { return; }
fields->properties.formatFailIfMoreThanMaxDigits = value;
touchNoError();
}
@ -1305,7 +1295,7 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const {
// so that CurrencyUsage is reflected properly.
// TODO: Consider putting this logic in number_patternstring.cpp instead.
ErrorCode localStatus;
DecimalFormatProperties tprops(*fields->properties);
DecimalFormatProperties tprops(fields->properties);
bool useCurrency = (
!tprops.currency.isNull() ||
!tprops.currencyPluralInfo.fPtr.isNull() ||
@ -1315,9 +1305,9 @@ UnicodeString& DecimalFormat::toPattern(UnicodeString& result) const {
AffixUtils::hasCurrencySymbols(tprops.negativePrefixPattern, localStatus) ||
AffixUtils::hasCurrencySymbols(tprops.negativeSuffixPattern, localStatus));
if (useCurrency) {
tprops.minimumFractionDigits = fields->exportedProperties->minimumFractionDigits;
tprops.maximumFractionDigits = fields->exportedProperties->maximumFractionDigits;
tprops.roundingIncrement = fields->exportedProperties->roundingIncrement;
tprops.minimumFractionDigits = fields->exportedProperties.minimumFractionDigits;
tprops.maximumFractionDigits = fields->exportedProperties.maximumFractionDigits;
tprops.roundingIncrement = fields->exportedProperties.roundingIncrement;
}
result = PatternStringUtils::propertiesToPatternString(tprops, localStatus);
return result;
@ -1373,49 +1363,49 @@ void DecimalFormat::applyLocalizedPattern(const UnicodeString& localizedPattern,
void DecimalFormat::setMaximumIntegerDigits(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->maximumIntegerDigits) { return; }
if (newValue == fields->properties.maximumIntegerDigits) { return; }
// For backwards compatibility, conflicting min/max need to keep the most recent setting.
int32_t min = fields->properties->minimumIntegerDigits;
int32_t min = fields->properties.minimumIntegerDigits;
if (min >= 0 && min > newValue) {
fields->properties->minimumIntegerDigits = newValue;
fields->properties.minimumIntegerDigits = newValue;
}
fields->properties->maximumIntegerDigits = newValue;
fields->properties.maximumIntegerDigits = newValue;
touchNoError();
}
void DecimalFormat::setMinimumIntegerDigits(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->minimumIntegerDigits) { return; }
if (newValue == fields->properties.minimumIntegerDigits) { return; }
// For backwards compatibility, conflicting min/max need to keep the most recent setting.
int32_t max = fields->properties->maximumIntegerDigits;
int32_t max = fields->properties.maximumIntegerDigits;
if (max >= 0 && max < newValue) {
fields->properties->maximumIntegerDigits = newValue;
fields->properties.maximumIntegerDigits = newValue;
}
fields->properties->minimumIntegerDigits = newValue;
fields->properties.minimumIntegerDigits = newValue;
touchNoError();
}
void DecimalFormat::setMaximumFractionDigits(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->maximumFractionDigits) { return; }
if (newValue == fields->properties.maximumFractionDigits) { return; }
// For backwards compatibility, conflicting min/max need to keep the most recent setting.
int32_t min = fields->properties->minimumFractionDigits;
int32_t min = fields->properties.minimumFractionDigits;
if (min >= 0 && min > newValue) {
fields->properties->minimumFractionDigits = newValue;
fields->properties.minimumFractionDigits = newValue;
}
fields->properties->maximumFractionDigits = newValue;
fields->properties.maximumFractionDigits = newValue;
touchNoError();
}
void DecimalFormat::setMinimumFractionDigits(int32_t newValue) {
if (fields == nullptr) { return; }
if (newValue == fields->properties->minimumFractionDigits) { return; }
if (newValue == fields->properties.minimumFractionDigits) { return; }
// For backwards compatibility, conflicting min/max need to keep the most recent setting.
int32_t max = fields->properties->maximumFractionDigits;
int32_t max = fields->properties.maximumFractionDigits;
if (max >= 0 && max < newValue) {
fields->properties->maximumFractionDigits = newValue;
fields->properties.maximumFractionDigits = newValue;
}
fields->properties->minimumFractionDigits = newValue;
fields->properties.minimumFractionDigits = newValue;
touchNoError();
}
@ -1425,7 +1415,7 @@ int32_t DecimalFormat::getMinimumSignificantDigits() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().minimumSignificantDigits;
}
return fields->exportedProperties->minimumSignificantDigits;
return fields->exportedProperties.minimumSignificantDigits;
}
int32_t DecimalFormat::getMaximumSignificantDigits() const {
@ -1434,28 +1424,28 @@ int32_t DecimalFormat::getMaximumSignificantDigits() const {
// Fallback to using the default instance of DecimalFormatProperties.
return DecimalFormatProperties::getDefault().maximumSignificantDigits;
}
return fields->exportedProperties->maximumSignificantDigits;
return fields->exportedProperties.maximumSignificantDigits;
}
void DecimalFormat::setMinimumSignificantDigits(int32_t value) {
if (fields == nullptr) { return; }
if (value == fields->properties->minimumSignificantDigits) { return; }
int32_t max = fields->properties->maximumSignificantDigits;
if (value == fields->properties.minimumSignificantDigits) { return; }
int32_t max = fields->properties.maximumSignificantDigits;
if (max >= 0 && max < value) {
fields->properties->maximumSignificantDigits = value;
fields->properties.maximumSignificantDigits = value;
}
fields->properties->minimumSignificantDigits = value;
fields->properties.minimumSignificantDigits = value;
touchNoError();
}
void DecimalFormat::setMaximumSignificantDigits(int32_t value) {
if (fields == nullptr) { return; }
if (value == fields->properties->maximumSignificantDigits) { return; }
int32_t min = fields->properties->minimumSignificantDigits;
if (value == fields->properties.maximumSignificantDigits) { return; }
int32_t min = fields->properties.minimumSignificantDigits;
if (min >= 0 && min > value) {
fields->properties->minimumSignificantDigits = value;
fields->properties.minimumSignificantDigits = value;
}
fields->properties->maximumSignificantDigits = value;
fields->properties.maximumSignificantDigits = value;
touchNoError();
}
@ -1466,7 +1456,7 @@ UBool DecimalFormat::areSignificantDigitsUsed() const {
// Fallback to using the default instance of DecimalFormatProperties.
dfp = &(DecimalFormatProperties::getDefault());
} else {
dfp = fields->properties.getAlias();
dfp = &fields->properties;
}
return dfp->minimumSignificantDigits != -1 || dfp->maximumSignificantDigits != -1;
}
@ -1476,20 +1466,20 @@ void DecimalFormat::setSignificantDigitsUsed(UBool useSignificantDigits) {
// These are the default values from the old implementation.
if (useSignificantDigits) {
if (fields->properties->minimumSignificantDigits != -1 ||
fields->properties->maximumSignificantDigits != -1) {
if (fields->properties.minimumSignificantDigits != -1 ||
fields->properties.maximumSignificantDigits != -1) {
return;
}
} else {
if (fields->properties->minimumSignificantDigits == -1 &&
fields->properties->maximumSignificantDigits == -1) {
if (fields->properties.minimumSignificantDigits == -1 &&
fields->properties.maximumSignificantDigits == -1) {
return;
}
}
int32_t minSig = useSignificantDigits ? 1 : -1;
int32_t maxSig = useSignificantDigits ? 6 : -1;
fields->properties->minimumSignificantDigits = minSig;
fields->properties->maximumSignificantDigits = maxSig;
fields->properties.minimumSignificantDigits = minSig;
fields->properties.maximumSignificantDigits = maxSig;
touchNoError();
}
@ -1503,11 +1493,11 @@ void DecimalFormat::setCurrency(const char16_t* theCurrency, UErrorCode& ec) {
}
CurrencyUnit currencyUnit(theCurrency, ec);
if (U_FAILURE(ec)) { return; }
if (!fields->properties->currency.isNull() && fields->properties->currency.getNoError() == currencyUnit) {
if (!fields->properties.currency.isNull() && fields->properties.currency.getNoError() == currencyUnit) {
return;
}
NumberFormat::setCurrency(theCurrency, ec); // to set field for compatibility
fields->properties->currency = currencyUnit;
fields->properties.currency = currencyUnit;
// TODO: Set values in fields->symbols, too?
touchNoError();
}
@ -1525,20 +1515,20 @@ void DecimalFormat::setCurrencyUsage(UCurrencyUsage newUsage, UErrorCode* ec) {
*ec = U_MEMORY_ALLOCATION_ERROR;
return;
}
if (!fields->properties->currencyUsage.isNull() && newUsage == fields->properties->currencyUsage.getNoError()) {
if (!fields->properties.currencyUsage.isNull() && newUsage == fields->properties.currencyUsage.getNoError()) {
return;
}
fields->properties->currencyUsage = newUsage;
fields->properties.currencyUsage = newUsage;
touch(*ec);
}
UCurrencyUsage DecimalFormat::getCurrencyUsage() const {
// CurrencyUsage is not exported, so we have to get it from the input property bag.
// TODO: Should we export CurrencyUsage instead?
if (fields == nullptr || fields->properties->currencyUsage.isNull()) {
if (fields == nullptr || fields->properties.currencyUsage.isNull()) {
return UCURR_USAGE_STANDARD;
}
return fields->properties->currencyUsage.getNoError();
return fields->properties.currencyUsage.getNoError();
}
void
@ -1550,7 +1540,7 @@ DecimalFormat::formatToDecimalQuantity(double number, DecimalQuantity& output, U
status = U_MEMORY_ALLOCATION_ERROR;
return;
}
fields->formatter->formatDouble(number, status).getDecimalQuantity(output, status);
fields->formatter.formatDouble(number, status).getDecimalQuantity(output, status);
}
void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQuantity& output,
@ -1564,7 +1554,7 @@ void DecimalFormat::formatToDecimalQuantity(const Formattable& number, DecimalQu
}
UFormattedNumberData obj;
number.populateDecimalQuantity(obj.quantity, status);
fields->formatter->formatImpl(&obj, status);
fields->formatter.formatImpl(&obj, status);
output = std::move(obj.quantity);
}
@ -1576,7 +1566,7 @@ const number::LocalizedNumberFormatter* DecimalFormat::toNumberFormatter(UErrorC
status = U_MEMORY_ALLOCATION_ERROR;
return nullptr;
}
return &*fields->formatter;
return &fields->formatter;
}
const number::LocalizedNumberFormatter& DecimalFormat::toNumberFormatter() const {
@ -1608,9 +1598,9 @@ void DecimalFormat::touch(UErrorCode& status) {
// Since memory has already been allocated for the formatter, we can move assign a stack-allocated object
// and don't need to call new. (Which is slower and could possibly fail).
*fields->formatter = NumberPropertyMapper::create(
*fields->properties, *fields->symbols, fields->warehouse, *fields->exportedProperties, status).locale(
locale);
fields->formatter = NumberPropertyMapper::create(
fields->properties, *fields->symbols, fields->warehouse, fields->exportedProperties, status
).locale(locale);
// Do this after fields->exportedProperties are set up
setupFastFormat();
@ -1620,13 +1610,13 @@ void DecimalFormat::touch(UErrorCode& status) {
delete fields->atomicCurrencyParser.exchange(nullptr);
// In order for the getters to work, we need to populate some fields in NumberFormat.
NumberFormat::setCurrency(fields->exportedProperties->currency.get(status).getISOCurrency(), status);
NumberFormat::setMaximumIntegerDigits(fields->exportedProperties->maximumIntegerDigits);
NumberFormat::setMinimumIntegerDigits(fields->exportedProperties->minimumIntegerDigits);
NumberFormat::setMaximumFractionDigits(fields->exportedProperties->maximumFractionDigits);
NumberFormat::setMinimumFractionDigits(fields->exportedProperties->minimumFractionDigits);
NumberFormat::setCurrency(fields->exportedProperties.currency.get(status).getISOCurrency(), status);
NumberFormat::setMaximumIntegerDigits(fields->exportedProperties.maximumIntegerDigits);
NumberFormat::setMinimumIntegerDigits(fields->exportedProperties.minimumIntegerDigits);
NumberFormat::setMaximumFractionDigits(fields->exportedProperties.maximumFractionDigits);
NumberFormat::setMinimumFractionDigits(fields->exportedProperties.minimumFractionDigits);
// fImpl->properties, not fields->exportedProperties, since this information comes from the pattern:
NumberFormat::setGroupingUsed(fields->properties->groupingUsed);
NumberFormat::setGroupingUsed(fields->properties.groupingUsed);
}
void DecimalFormat::touchNoError() {
@ -1639,7 +1629,7 @@ void DecimalFormat::setPropertiesFromPattern(const UnicodeString& pattern, int32
if (U_SUCCESS(status)) {
// Cast workaround to get around putting the enum in the public header file
auto actualIgnoreRounding = static_cast<IgnoreRounding>(ignoreRounding);
PatternParser::parseToExistingProperties(pattern, *fields->properties, actualIgnoreRounding, status);
PatternParser::parseToExistingProperties(pattern, fields->properties, actualIgnoreRounding, status);
}
}
@ -1658,7 +1648,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getParser(UErrorCode& sta
}
// Try computing the parser on our own
auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, false, status);
auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, false, status);
if (U_FAILURE(status)) {
return nullptr;
}
@ -1691,7 +1681,7 @@ const numparse::impl::NumberParserImpl* DecimalFormat::getCurrencyParser(UErrorC
}
// Try computing the parser on our own
auto* temp = NumberParserImpl::createParserFromProperties(*fields->properties, *fields->symbols, true, status);
auto* temp = NumberParserImpl::createParserFromProperties(fields->properties, *fields->symbols, true, status);
if (temp == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
// although we may still dereference, call sites should be guarded
@ -1739,7 +1729,7 @@ DecimalFormat::fieldPositionIteratorHelper(const number::FormattedNumber& format
void DecimalFormat::setupFastFormat() {
// Check the majority of properties:
if (!fields->properties->equalsDefaultExceptFastFormat()) {
if (!fields->properties.equalsDefaultExceptFastFormat()) {
trace("no fast format: equality\n");
fields->canUseFastFormat = false;
return;
@ -1747,12 +1737,12 @@ void DecimalFormat::setupFastFormat() {
// Now check the remaining properties.
// Nontrivial affixes:
UBool trivialPP = fields->properties->positivePrefixPattern.isEmpty();
UBool trivialPS = fields->properties->positiveSuffixPattern.isEmpty();
UBool trivialNP = fields->properties->negativePrefixPattern.isBogus() || (
fields->properties->negativePrefixPattern.length() == 1 &&
fields->properties->negativePrefixPattern.charAt(0) == u'-');
UBool trivialNS = fields->properties->negativeSuffixPattern.isEmpty();
UBool trivialPP = fields->properties.positivePrefixPattern.isEmpty();
UBool trivialPS = fields->properties.positiveSuffixPattern.isEmpty();
UBool trivialNP = fields->properties.negativePrefixPattern.isBogus() || (
fields->properties.negativePrefixPattern.length() == 1 &&
fields->properties.negativePrefixPattern.charAt(0) == u'-');
UBool trivialNS = fields->properties.negativeSuffixPattern.isEmpty();
if (!trivialPP || !trivialPS || !trivialNP || !trivialNS) {
trace("no fast format: affixes\n");
fields->canUseFastFormat = false;
@ -1760,8 +1750,8 @@ void DecimalFormat::setupFastFormat() {
}
// Grouping (secondary grouping is forbidden in equalsDefaultExceptFastFormat):
bool groupingUsed = fields->properties->groupingUsed;
int32_t groupingSize = fields->properties->groupingSize;
bool groupingUsed = fields->properties.groupingUsed;
int32_t groupingSize = fields->properties.groupingSize;
bool unusualGroupingSize = groupingSize > 0 && groupingSize != 3;
const UnicodeString& groupingString = fields->symbols->getConstSymbol(DecimalFormatSymbols::kGroupingSeparatorSymbol);
if (groupingUsed && (unusualGroupingSize || groupingString.length() != 1)) {
@ -1771,8 +1761,8 @@ void DecimalFormat::setupFastFormat() {
}
// Integer length:
int32_t minInt = fields->exportedProperties->minimumIntegerDigits;
int32_t maxInt = fields->exportedProperties->maximumIntegerDigits;
int32_t minInt = fields->exportedProperties.minimumIntegerDigits;
int32_t maxInt = fields->exportedProperties.maximumIntegerDigits;
// Fastpath supports up to only 10 digits (length of INT32_MIN)
if (minInt > 10) {
trace("no fast format: integer\n");
@ -1781,7 +1771,7 @@ void DecimalFormat::setupFastFormat() {
}
// Fraction length (no fraction part allowed in fast path):
int32_t minFrac = fields->exportedProperties->minimumFractionDigits;
int32_t minFrac = fields->exportedProperties.minimumFractionDigits;
if (minFrac > 0) {
trace("no fast format: fraction\n");
fields->canUseFastFormat = false;

View file

@ -126,8 +126,14 @@ struct DecimalFormatWarehouse {
* TODO: Make some of these fields by value instead of by LocalPointer?
*/
struct DecimalFormatFields : public UMemory {
DecimalFormatFields() {}
DecimalFormatFields(const DecimalFormatProperties& propsToCopy)
: properties(propsToCopy) {}
/** The property bag corresponding to user-specified settings and settings from the pattern string. */
LocalPointer<DecimalFormatProperties> properties;
DecimalFormatProperties properties;
/** The symbols for the current locale. */
LocalPointer<const DecimalFormatSymbols> symbols;
@ -136,7 +142,7 @@ struct DecimalFormatFields : public UMemory {
* The pre-computed formatter object. Setters cause this to be re-computed atomically. The {@link
* #format} method uses the formatter directly without needing to synchronize.
*/
LocalPointer<LocalizedNumberFormatter> formatter;
LocalizedNumberFormatter formatter;
/** The lazy-computed parser for .parse() */
std::atomic<::icu::numparse::impl::NumberParserImpl*> atomicParser = {};
@ -148,7 +154,7 @@ struct DecimalFormatFields : public UMemory {
DecimalFormatWarehouse warehouse;
/** The effective properties as exported from the formatter object. Used by some getters. */
LocalPointer<DecimalFormatProperties> exportedProperties;
DecimalFormatProperties exportedProperties;
// Data for fastpath
bool canUseFastFormat = false;