8330802: Desugar switch in Locale::createLocale

Reviewed-by: alanb, liach, rriggs, naoto, mchung
This commit is contained in:
Claes Redestad 2024-04-23 08:00:07 +00:00
parent 8961077056
commit daa5a4bd12

View File

@ -995,11 +995,11 @@ public final class Locale implements Cloneable, Serializable {
private static final ReferencedKeyMap<Object, Locale> LOCALE_CACHE = ReferencedKeyMap.create(true, ConcurrentHashMap::new);
private static Locale createLocale(Object key) {
return switch (key) {
case BaseLocale base -> new Locale(base, null);
case LocaleKey lk -> new Locale(lk.base, lk.exts);
default -> throw new InternalError("should not happen");
};
if (key instanceof BaseLocale base) {
return new Locale(base, null);
}
LocaleKey lk = (LocaleKey)key;
return new Locale(lk.base, lk.exts);
}
private static final class LocaleKey {