Proposal: optimization of Map.copyOf and Collectors.toUnmodifiableMap

Stuart Marks stuart.marks at oracle.com
Tue Jun 19 00:55:29 UTC 2018



On 6/18/18 7:25 AM, Roger Riggs wrote:
> In regard to new SharedSecret interfaces, one option is move shared (but 
> private) implementation classes
> to a jdk.internal.xx package (not exported).  This only works well if they are 
> not tightly coupled to other
> package private classes.
> 
> SpinedBuffer might be a good candidate, I have some IO cases in mind that could 
> benefit from
> the allocation/reallocation savings.  (ByteArrayOutputStream for 1).

Yes, SpinedBuffer is a good candidate for this. There's nothing special about it 
that ties it to streams. It was just put into java.util.stream because streams 
were its initial (and currently only) users.

A SharedSecret would be helpful for things like new private factory methods for 
the unmodifiable collections, such as ones that might assume ownership of an 
array instead of copying it.

s'marks


More information about the core-libs-dev mailing list