On Wed, 16 Aug 2023 05:02:36 GMT, Nir Lisker <nlis...@openjdk.org> wrote:

>> Almost, but the key is also the copied set.  In your version the key is the 
>> original object, which may be a modifiable set.  If the key is modified, the 
>> cache will not function correctly anymore.
>> 
>> I had a different version before, but @mstr2 pointed out that there was an 
>> unnecessary allocation in that version which this version avoids.
>
> Then the map is just an optimization? If the set points to itself then a 
> `Set` as a cache should be enough.

No, a `Set` wouldn't work here, for this reason:

      if (CACHE.contains(mutableSet)) {
             return ... // how do I get the immutable set from CACHE when it is 
a Set?
      }

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1076#discussion_r1295967620

Reply via email to