trivial patch to reduce allocations in nio open* methods

Chris Hegarty chris.hegarty at oracle.com
Tue Mar 6 18:34:21 UTC 2018


On 06/03/18 17:40, Alan Bateman wrote:
> On 06/03/2018 08:17, Michael Skells wrote:
>> Hi,
>> below is a trivial patch to reduce allocation on the file open call 
>> path, when no OpenOption is specified( which is a common case in my 
>> test code at least)
>>
>> There is some duplication of empty set  handling, but I could not see 
>> a suitable utility class to provide this and didnt want to create a 
>> public method
> I think we should start by changing the methods that take varargs so 
> that they use the static factory methods for immutable collections, e.g. 
> Set.of(options). That would be a good cleanup before seeing it's wroth 
> trying to do more for the zero options case.

It seems crummy, but using Set.of will require some care when
handling duplicate options. The code currently silently ignores
duplicates, if I'm not mistaken.

-Chris.


More information about the nio-dev mailing list