Sized Collector supplier
Tagir Valeev
amaembo at gmail.com
Tue Sep 18 15:19:47 UTC 2018
Hello!
See the ticket:
https://bugs.openjdk.java.net/browse/JDK-8072840
In my opinion only toList and toUnmodifiableList collectors would benefit
significantly, but this could be solved in alternative way, adding the
corresponding methods to the stream interface. Another possibility is to
add a hidden API for this case (e. g. add new method to CollectorImpl and
branch on `instanceof CollectorImpl` inside ReferencePipeline.collect`).
This would add a performance benefit for JDK collectors and JDK stream
implementation without exposing new API. If somebody interested, I can
implement this. In general I don't think that improvement of a couple of
collectors performance justifies increasing public API complexity.
To my opinion Collectors would benefit much more if they support
short-circuiting. There are much more interesting use-cases which could be
covered with short-circuiting collectors.
With best regards,
Tagir Valeev.
вт, 18 сент. 2018 г., 16:39 Roman Leventov <leventov.ru at gmail.com>:
> Is there a reason why java.util.stream.Collector doesn't support sized
> supply of a mutable result container? It seems that it could be hugely
> beneficial when the size of the stream is known, e. g. for precise
> ArrayList and HashMap.
>
More information about the core-libs-dev
mailing list