On Thu, 13 Nov 2025 03:09:21 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
>> modules/javafx.swing/src/main/java/javafx/embed/swing/JFXPanel.java line 212:
>>
>>> 210:
>>> 211: private static void debug_println(String str) {
>>> 212: if (DEBUG) {
>>
>> I am sorry, I was not sufficiently clear.
>> This method does not need the conditional. The conditionals are needed in
>> **every** place that calls here.
>> In other words, we don't want to incur the string concatenation overhead if
>> **DEBUG** is false.
>
> will that be too much overhead? We had used the same in jdk having DEBUG
> check in one place...but I will modify it for FX..
Then you might want to fix all these places in JDK!
The code you currently have now (after
https://github.com/openjdk/jfx/pull/1968/commits/115001f6c92b587574c67624f0033cabaabe04d0
) has minimum runtime overhead - basically a boolean check.
Anything else consumes more CPU and memory at runtime (we don't have a
pre-processor in java thankfully), so `if(DEBUG) { debug_print(...); }` is the
best, albeit a bit verbose option.
Event the modern logging facades incur more overhead with lambdas or formats,
since one needs to actually enter the logging function to check whether the
level/logger is enabled. I mean `logger.debug("param {}", param);` or
`logger.debug("param {}", () -> param());`
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1968#discussion_r2524388270