Due to debugging reason most parts of the code in my application has this recurrent portion of code:
public static final boolean DEBUG = true; // just created once in a "Utility" class
if (Utility.DEBUG)
Log.d("TIMER", /*string message that is strictly related to context*/);
Now, if the boolean values turn to false
this becomes dead code. My question is if in this case the Android compiler would do basics optimizations such as constant folding and dead code remotion?
If the answer is no, what is the best way to whip out in release phase the debugging logs?
Yes; in the case of static final
fields the compiler can and will remove the unreachable section. If you examine the byte-code you can validate this yourself.
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