RFR: JDK-8306860: Avoid unnecessary allocation in List.map() when list is empty
ExE Boss
duke at openjdk.org
Tue Apr 25 15:41:57 UTC 2023
On Mon, 10 Apr 2023 17:44:37 GMT, Lalit Prakash Vatsal <duke at openjdk.org> wrote:
>> Same "problem". This changes behaviour compared to what it does now. I don't have anything against that per se, but an optimization imho shouldn't really change the behaviour.
>
> I agree with @dreis2211 here. Someone might want to use/mutate the returned `List` later on.
This won’t be a change in behaviour as `ListBuffer::toList()` returns `List.nil()` when called on an empty `ListBuffer`.
--------------------------------------------------------------------------------
e.g.: The following evaluates to `true`:
new ListBuffer().toList() == List.nil()
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13407#discussion_r1162591007
More information about the compiler-dev
mailing list