mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-7434 switch ULocale from SimpleCache to SoftCache
X-SVN-Rev: 38740
This commit is contained in:
parent
fec331c017
commit
33e71967fc
2 changed files with 18 additions and 17 deletions
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
import java.util.MissingResourceException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.icu.impl.CacheBase;
|
||||
import com.ibm.icu.impl.ICUCache;
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
import com.ibm.icu.impl.ICUDebug;
|
||||
|
@ -229,7 +230,7 @@ public class Currency extends MeasureUnit {
|
|||
}
|
||||
|
||||
private static final String EUR_STR = "EUR";
|
||||
private static final SoftCache<String, Currency, Void> regionCurrencyCache =
|
||||
private static final CacheBase<String, Currency, Void> regionCurrencyCache =
|
||||
new SoftCache<String, Currency, Void>() {
|
||||
@Override
|
||||
protected Currency createInstance(String key, Void unused) {
|
||||
|
|
|
@ -24,14 +24,14 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.ibm.icu.impl.ICUCache;
|
||||
import com.ibm.icu.impl.CacheBase;
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
import com.ibm.icu.impl.ICUResourceTableAccess;
|
||||
import com.ibm.icu.impl.LocaleIDParser;
|
||||
import com.ibm.icu.impl.LocaleIDs;
|
||||
import com.ibm.icu.impl.LocaleUtility;
|
||||
import com.ibm.icu.impl.SimpleCache;
|
||||
import com.ibm.icu.impl.SoftCache;
|
||||
import com.ibm.icu.impl.locale.AsciiUtil;
|
||||
import com.ibm.icu.impl.locale.BaseLocale;
|
||||
import com.ibm.icu.impl.locale.Extension;
|
||||
|
@ -115,7 +115,12 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
|||
// using serialver from jdk1.4.2_05
|
||||
private static final long serialVersionUID = 3715177670352309217L;
|
||||
|
||||
private static ICUCache<String, String> nameCache = new SimpleCache<String, String>();
|
||||
private static CacheBase<String, String, Void> nameCache = new SoftCache<String, String, Void>() {
|
||||
@Override
|
||||
protected String createInstance(String tmpLocaleID, Void unused) {
|
||||
return new LocaleIDParser(tmpLocaleID).getName();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Useful constant for language.
|
||||
|
@ -305,7 +310,12 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
|||
FORMAT
|
||||
}
|
||||
|
||||
private static final SimpleCache<Locale, ULocale> CACHE = new SimpleCache<Locale, ULocale>();
|
||||
private static final SoftCache<Locale, ULocale, Void> CACHE = new SoftCache<Locale, ULocale, Void>() {
|
||||
@Override
|
||||
protected ULocale createInstance(Locale key, Void unused) {
|
||||
return JDKLocaleHelper.toULocale(key);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache the locale.
|
||||
|
@ -442,12 +452,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
|||
if (loc == null) {
|
||||
return null;
|
||||
}
|
||||
ULocale result = CACHE.get(loc);
|
||||
if (result == null) {
|
||||
result = JDKLocaleHelper.toULocale(loc);
|
||||
CACHE.put(loc, result);
|
||||
}
|
||||
return result;
|
||||
return CACHE.getInstance(loc, null /* unused */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1165,12 +1170,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
|||
} else {
|
||||
tmpLocaleID = localeID;
|
||||
}
|
||||
String name = nameCache.get(tmpLocaleID);
|
||||
if (name == null) {
|
||||
name = new LocaleIDParser(tmpLocaleID).getName();
|
||||
nameCache.put(tmpLocaleID, name);
|
||||
}
|
||||
return name;
|
||||
return nameCache.getInstance(tmpLocaleID, null /* unused */);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue