On Thu, 3 Dec 2020 22:54:54 GMT, Mandy Chung <mch...@openjdk.org> wrote:

> This patch replaces some uses of `Reference::get` to `Reference::refersTo` to 
> avoid keeping a referent strongly reachable that could cause unnecessary 
> delay in collecting such object.   I only made change in some but not all 
> classes in core libraries when working with Kim on `Reference::refersTo`.    
> The remaining uses are left for the component owners to convert at 
> appropriate time.

src/java.base/share/classes/java/util/WeakHashMap.java line 293:

> 291:         // then checks for equality
> 292:         Object k = e.get();
> 293:         return key == k || key.equals(k);

I think `key == k` is already covered by refersTo. But k could be null; 
checking for that here might be useful, to skip the call to equals in that case.

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

PR: https://git.openjdk.java.net/jdk/pull/1609

Reply via email to