On Tue, 22 Apr 2025 11:22:52 GMT, Per Minborg <pminb...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/ImmutableCollections.java line 1592:
>> 
>>> 1590:                     final K k = inner.getKey();
>>> 1591:                     return new NullableKeyValueHolder<>(k, 
>>> inner.getValue().orElseSet(new Supplier<V>() {
>>> 1592:                         @Override public V get() { return 
>>> mapper.apply(k); }}));
>> 
>> I suppose you could potentially make this more lazy by returning an `Entry` 
>> implementation that only evaluates the mapper when calling `Entry::getValue`.
>
> Yepp. Interesting idea.

This lazy `Entry` implementation should then also have a `toString` that 
doesn't evaluate the contents. It should also be used in `forEachRemaining`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23972#discussion_r2059377365

Reply via email to