On Thu, 1 Dec 2022 22:23:20 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> John Hendrikx has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   Adjust Node
>>   
>>   - Fixed javadoc
>>   - Added comment for code that avoid eager instantiation
>>   - Changed `isShown` to use property if it is available
>
> modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 1453:
> 
>> 1451:         private final ObservableValue<Boolean> delegate;
>> 1452:         private final Object bean;
>> 1453:         private final String name;
> 
> You could omit the `bean` and `name` fields by making this a non-static inner 
> class and returning `Node.this` and `"shown"` directly from `getBean()` and 
> `getName()` respectively. In that case, you could also make this class an 
> anonymous implementation of `ReadOnlyBooleanProperty`. This pattern is used 
> quite extensively in JavaFX, since it can potentially save a few bytes of 
> memory.

I don't mind changing it, but I should point out, it is already lazily created. 
 Once it does get created, you would save 8 bytes in the best case (assuming 
alignment is 8 bytes).

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

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

Reply via email to