mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8196869: Optimize Locale creation
Reviewed-by: psandoz, plevart, naoto
This commit is contained in:
parent
8dcabfdf5f
commit
9f0da6d94f
4 changed files with 188 additions and 121 deletions
|
@ -808,17 +808,26 @@ public final class Locale implements Cloneable, Serializable {
|
|||
}
|
||||
|
||||
static Locale getInstance(BaseLocale baseloc, LocaleExtensions extensions) {
|
||||
LocaleKey key = new LocaleKey(baseloc, extensions);
|
||||
return LOCALECACHE.get(key);
|
||||
if (extensions == null) {
|
||||
return LOCALECACHE.get(baseloc);
|
||||
} else {
|
||||
LocaleKey key = new LocaleKey(baseloc, extensions);
|
||||
return LOCALECACHE.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Cache extends LocaleObjectCache<LocaleKey, Locale> {
|
||||
private static class Cache extends LocaleObjectCache<Object, Locale> {
|
||||
private Cache() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Locale createObject(LocaleKey key) {
|
||||
return new Locale(key.base, key.exts);
|
||||
protected Locale createObject(Object key) {
|
||||
if (key instanceof BaseLocale) {
|
||||
return new Locale((BaseLocale)key, null);
|
||||
} else {
|
||||
LocaleKey lk = (LocaleKey)key;
|
||||
return new Locale(lk.base, lk.exts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue