trivial patch to reduce allocations in nio open* methods
brian.burkhalter at oracle.com
Wed Jun 20 00:23:53 UTC 2018
Picking up this thread from  after a few months. A new patch is available at . The changes versus version .00 are at .
On Mar 30, 2018, at 1:27 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 30/03/2018 02:11, Brian Burkhalter wrote:
>> I created a webrev of this patch:
>> http://cr.openjdk.java.net/~bpb/8199124/webrev.00/ <http://cr.openjdk.java.net/%7Ebpb/8199124/webrev.00/>
>> I don’t see any problem in moving forward with it, possibly with some minor cleanup.
> Just a few comments.
> The sizing of the hash map doesn't take the load factor into account. You might find `new HashMap<>(1 + (4 * options.length/ 3)` a bit better with a larger array of options.
I don’t see what you are referring to. There is no use of HashMap in these classes. The HashSets are created to be of a fixed size as they are not resized later. Perhaps Set.of(E… elements) should be used to create these Sets?
> You can use an immutable set to avoid wrapping the EnumSet, e.g.
> private static final Set<OpenOption> DEFAULT_CREATE_OPTIONS = Set.of(CREATE_NEW, WRITE);
The two occurrences like this are changed according to the suggestion.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nio-dev