trivial patch to reduce allocations in nio open* methods

Alan Bateman Alan.Bateman at oracle.com
Tue Apr 3 07:58:23 UTC 2018


On 30/03/2018 16:15, Brian Burkhalter wrote:
>
> On Mar 30, 2018, at 1:27 AM, Alan Bateman <Alan.Bateman at oracle.com 
> <mailto:Alan.Bateman at oracle.com>> wrote:
>
>> 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);
>
> I was wondering whether the DEFAULT_*_OPTIONS constants should be 
> created at all, i.e., kept around as static finals.
>
His issue is that each call to createFile, newOutputStream and others 
create a HashSet with the default set of options. The static finals are 
to avoid creating these each time. It would of course be useful to have 
some real performance data to see if it helps or not.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180403/fd4aa0e2/attachment.html>


More information about the nio-dev mailing list