RFR: JDK-8306860: Avoid unnecessary allocation in List.map() when list is empty

Christoph Dreis duke at openjdk.org
Tue Apr 25 15:41:54 UTC 2023


On Mon, 10 Apr 2023 17:34:00 GMT, ExE Boss <duke at openjdk.org> wrote:

>> Wouldn't this change the logic compared to what it did before? If the list gets mutated later - e.g. via `setTail` - this would fail with `List.nil()`.
>> Do I miss something here?
>
> I meant the list on which `map(…)` is called.

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.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13407#discussion_r1161927479


More information about the compiler-dev mailing list