Skip to content

Commit

Permalink
8289706: (cs) Avoid redundant TreeMap.containsKey call in AbstractCha…
Browse files Browse the repository at this point in the history
…rsetProvider

Reviewed-by: attila, naoto
  • Loading branch information
Andrey Turbanov committed Jul 6, 2022
1 parent fafe8b3 commit f783244
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,7 +31,6 @@
import java.util.ArrayList;
import java.util.TreeMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;


Expand Down Expand Up @@ -75,14 +74,6 @@ protected AbstractCharsetProvider(String pkgPrefixName) {
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) {
V x = m.remove(name);
assert (x != null);
Expand All @@ -92,10 +83,10 @@ private static <K,V> void remove(Map<K,V> m, K name) {
*/
protected void charset(String name, String className, String[] aliases) {
synchronized (this) {
put(classMap, name, className);
classMap.putIfAbsent(name, className);
for (int i = 0; i < aliases.length; i++)
put(aliasMap, aliases[i], name);
put(aliasNameMap, name, aliases);
aliasMap.putIfAbsent(aliases[i], name);
aliasNameMap.putIfAbsent(name, aliases);
cache.clear();
}
}
Expand Down

1 comment on commit f783244

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.