Are tightly tuned conditions optimized JVMs in Android?

Due to the debugging reason, most parts of the code in my application have this repeating piece 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 booleans refer to false, it becomes dead code. My question is, will the Android compiler do basic optimizations in this case, such as persistent folding and remote code?

If the answer is no, what is the best way to clear debug logs in the free phase?

+4
source share
1 answer

Yes; in the case of fields, the static finalcompiler can delete and delete an unreachable section. If you learn bytecode , you can check it yourself.

+5

Source: https://habr.com/ru/post/1693696/


All Articles