RFR: 8281298: Revise the creation of unmodifiable list

Xue-Lei Andrew Fan xuelei at openjdk.java.net
Mon Feb 7 05:52:06 UTC 2022


On Sun, 6 Feb 2022 22:11:06 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> This looks like an appropriate solution which avoids the minor compatibility risk introduced by the previous change - and you might even end up being more efficient both when setting and reading the names/matchers.
> 
> (Since we're going down the route of optimizing this: the `type` of a `SNIServerName` is constrained to a value between 0 and 255, so there's likely a small micro-optimization opportunity in using a `BitSet` for the duplicate checking rather a `ArrayList<Integer>`.. A `BitSet(256)` should have lower memory use and the existence check will run in O(1) instead of O(n) time. Might not be worthwhile to optimize these setters, though..)

Thank you for the quick review.  As the number of SNIServerName is normally one in practice, I'm not very sure of the improvement to use BitSet yet.  But I'm glad to know the BitSet could be a better choice if the items number goes beyond 4.

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

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



More information about the security-dev mailing list