8289706: (cs) Avoid redundant TreeMap.containsKey call in AbstractCharsetProvider
Reviewed-by: attila, naoto
This commit is contained in:
parent
fafe8b3f8d
commit
f783244caf
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,7 +31,6 @@ import java.nio.charset.spi.CharsetProvider;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@ -75,14 +74,6 @@ public class AbstractCharsetProvider
|
|||||||
packagePrefix = pkgPrefixName.concat(".");
|
packagePrefix = pkgPrefixName.concat(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add an entry to the given map, but only if no mapping yet exists
|
|
||||||
* for the given name.
|
|
||||||
*/
|
|
||||||
private static <K,V> void put(Map<K,V> m, K name, V value) {
|
|
||||||
if (!m.containsKey(name))
|
|
||||||
m.put(name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <K,V> void remove(Map<K,V> m, K name) {
|
private static <K,V> void remove(Map<K,V> m, K name) {
|
||||||
V x = m.remove(name);
|
V x = m.remove(name);
|
||||||
assert (x != null);
|
assert (x != null);
|
||||||
@ -92,10 +83,10 @@ public class AbstractCharsetProvider
|
|||||||
*/
|
*/
|
||||||
protected void charset(String name, String className, String[] aliases) {
|
protected void charset(String name, String className, String[] aliases) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
put(classMap, name, className);
|
classMap.putIfAbsent(name, className);
|
||||||
for (int i = 0; i < aliases.length; i++)
|
for (int i = 0; i < aliases.length; i++)
|
||||||
put(aliasMap, aliases[i], name);
|
aliasMap.putIfAbsent(aliases[i], name);
|
||||||
put(aliasNameMap, name, aliases);
|
aliasNameMap.putIfAbsent(name, aliases);
|
||||||
cache.clear();
|
cache.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user