RFR: 8290040: Provide simplified deterministic way to manage listeners [v6]

Nir Lisker nlisker at openjdk.org
Thu Dec 1 10:38:09 UTC 2022


On Wed, 26 Oct 2022 06:52:17 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 1426:
>> 
>>> 1424:         if (s == null) return false;
>>> 1425:         Window w = s.getWindow();
>>> 1426:         return w != null && w.isShowing();
>> 
>> Are you avoiding calling `get` on the property to avoid its initialization?
>
> Yeah, I actually copied this pattern from an older method that has since been removed (`isWindowShowing`) in an effort to avoid initializing the property if all you're doing is calling its getter.  I personally don't mind either way, but as it seems `Node` goes through every effort to delay initialization, I followed that pattern.  It does duplicate the logic of the property which uses `flatMap`s to achieve the same.

I would suggest adding a comment saying that this is done to avoid initialization.

I'm not sure that it's that critical for performance, to be honest.

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

PR: https://git.openjdk.org/jfx/pull/830


More information about the openjfx-dev mailing list