trivial patch to reduce allocations in nio open* methods

Alan Bateman Alan.Bateman at oracle.com
Wed Jun 20 08:52:01 UTC 2018



On 20/06/2018 01:23, Brian Burkhalter wrote:
> :
>>
>> 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?
>
>
FileSystemProvider L430. This has been changed to create the HashSet 
with an initial capacity of len+1 so it's ignoring the load factor. I'm 
just saying that the 4 places where this has changed can be improved to 
avoid resizing every time. Given that the number of options is small is 
almost all cases then it may be simpler to just use the no-arg 
constructor for now.

-Alan

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


More information about the nio-dev mailing list