Integrated: 8286366: (cs) Charset.put can use putIfAbsent instead of containsKey+put
Andrey Turbanov
aturbanov at openjdk.java.net
Wed May 18 17:47:40 UTC 2022
On Sat, 30 Apr 2022 08:27:10 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> The method `Charset.put(Iterator<Charset> i, Map<String,Charset> m)` could be improved by usage of `Map.putIfAbsent` instead of pair `containsKey`+`put`. This method is called only with `TreeMap` as an argument and `TreeMap` has an effective implementation of `putIfAbsent` which avoid traversal Tree twice.
> According to [JDK-8176894](https://bugs.openjdk.java.net/browse/JDK-8176894) usage of `TreeMap.putIfAbsent` could improve performance by 40%-100% compared with previous approach.
This pull request has now been integrated.
Changeset: 6b9c1521
Author: Andrey Turbanov <aturbanov at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/6b9c15211efd0eb35e4ac8edf84c61bb8825a027
Stats: 2 lines in 1 file changed: 0 ins; 1 del; 1 mod
8286366: (cs) Charset.put can use putIfAbsent instead of containsKey+put
Reviewed-by: alanb
-------------
PR: https://git.openjdk.java.net/jdk/pull/8480
More information about the nio-dev
mailing list