RFR: 8270317: Large Allocation in CipherSuite

djelinski github.com+30433125+djelinski at openjdk.java.net
Thu Jul 15 17:55:11 UTC 2021


On Thu, 15 Jul 2021 16:39:14 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

>> src/java.base/share/classes/sun/security/ssl/CipherSuite.java line 916:
>> 
>>> 914:     static String nameOf(int id) {
>>> 915:         if (maps_id.containsKey(id)) {
>>> 916:             return maps_id.get(id).name;
>> 
>> Would it make sense to skip `containsKey` and null-check the value returned by `get` instead?
>
> That's what containsKey() does, returning false of the value is null.

Right. But calling `containsKey` and then `get` results in two hash map lookups. If we cache the result of `get`, we only need one lookup, which should be a tiny bit faster. See https://stackoverflow.com/q/14601016

-------------

PR: https://git.openjdk.java.net/jdk/pull/4783



More information about the security-dev mailing list