ICU-13526 Adding package-private getNumberFormatInternal() to reduce unnecessary object cloning.
X-SVN-Rev: 40835
This commit is contained in:
parent
bf49bd2afc
commit
4385fb0348
@ -58,7 +58,7 @@ class CurrencyFormat extends MeasureFormat {
|
||||
*/
|
||||
@Override
|
||||
public CurrencyAmount parseObject(String source, ParsePosition pos) {
|
||||
return getNumberFormat().parseCurrency(source, pos);
|
||||
return getNumberFormatInternal().parseCurrency(source, pos);
|
||||
}
|
||||
|
||||
// Serialization
|
||||
|
@ -494,7 +494,7 @@ public class MeasureFormat extends UFormat {
|
||||
// A very slow but safe implementation.
|
||||
return getWidth() == rhs.getWidth()
|
||||
&& getLocale().equals(rhs.getLocale())
|
||||
&& getNumberFormat().equals(rhs.getNumberFormat());
|
||||
&& getNumberFormatInternal().equals(rhs.getNumberFormatInternal());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -505,7 +505,7 @@ public class MeasureFormat extends UFormat {
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
// A very slow but safe implementation.
|
||||
return (getLocale().hashCode() * 31 + getNumberFormat().hashCode()) * 31 + getWidth().hashCode();
|
||||
return (getLocale().hashCode() * 31 + getNumberFormatInternal().hashCode()) * 31 + getWidth().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,6 +535,13 @@ public class MeasureFormat extends UFormat {
|
||||
return (NumberFormat) numberFormat.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of the number format without cloning. Internal method.
|
||||
*/
|
||||
NumberFormat getNumberFormatInternal() {
|
||||
return numberFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formatter for CurrencyAmount objects in the given locale.
|
||||
*
|
||||
@ -954,15 +961,15 @@ public class MeasureFormat extends UFormat {
|
||||
}
|
||||
|
||||
Object toTimeUnitProxy() {
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), TIME_UNIT_FORMAT);
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), TIME_UNIT_FORMAT);
|
||||
}
|
||||
|
||||
Object toCurrencyProxy() {
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), CURRENCY_FORMAT);
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), CURRENCY_FORMAT);
|
||||
}
|
||||
|
||||
private Object writeReplace() throws ObjectStreamException {
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormat(), MEASURE_FORMAT);
|
||||
return new MeasureProxy(getLocale(), formatWidth, getNumberFormatInternal(), MEASURE_FORMAT);
|
||||
}
|
||||
|
||||
static class MeasureProxy implements Externalizable {
|
||||
|
@ -150,7 +150,7 @@ public class TimeUnitFormat extends MeasureFormat {
|
||||
@Deprecated
|
||||
public TimeUnitFormat(ULocale locale, int style) {
|
||||
super(locale, style == FULL_NAME ? FormatWidth.WIDE : FormatWidth.SHORT);
|
||||
format = super.getNumberFormat();
|
||||
format = super.getNumberFormatInternal();
|
||||
if (style < FULL_NAME || style >= TOTAL_STYLES) {
|
||||
throw new IllegalArgumentException("style should be either FULL_NAME or ABBREVIATED_NAME style");
|
||||
}
|
||||
@ -225,6 +225,11 @@ public class TimeUnitFormat extends MeasureFormat {
|
||||
|
||||
@Override
|
||||
public NumberFormat getNumberFormat() {
|
||||
return (NumberFormat) format.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
NumberFormat getNumberFormatInternal() {
|
||||
return format;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user