Please take a look at this code android sample :
private static final boolean aBoolean = false;
...
if(aBoolean){
//do something like logs
}
In this case since the value of aBoolean is false and that it can't change at runtime, would the //do something like logs statement be ignored by on build or will it be still be build and each time it will evaluate the if?
I'm trying to find a behavior like pre processor #DEFINE #IF... so that when I'm coding I get my logs, when I release I switch one value and all my debug code gets completely ignored.
(also I would like to point out that my question is android oriented so if there is a difference between Java and Android on this matter please let me know)
Checking a variable for logging is perfectly find. Even if the code doesn't get optimised out, checking a boolean condition is almost a no-op and you are very prematurely optimising.
But to answer your question, it probably gets optimised out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With