android.util.Config.DEBUG is true if this is a debug build.

import static android.util.Config.DEBUG;

if (DEBUG) ...

On Oct 2, 9:48 am, Dianne Hackborn <[email protected]> wrote:
> Yeah you will still get the concats, which you really don't want to keep
> (those are really expensive).  We typically write logging like this:
>   if (DEBUG) Log.v("foo", "this is something: " + something);
>
> Then when DEBUG is false the entire statement, including string
> concatenation, is stripped.
>
>
>
> On Fri, Oct 2, 2009 at 9:17 AM, Dan Sherman <[email protected]> wrote:
> > I would imagine it does the string concat and then disregards it.  It would
> > concat, pass the final string to the function, fail the if, return, and
> > discard the string...
>
> > - Dan
>
> > On Fri, Oct 2, 2009 at 9:31 AM, jsdf <[email protected]> wrote:
>
> >> Hi all,
>
> >> I have been using the following conventions for my applications:
>
> >> - I define a static log(String msg) function centrally as:
> >> public static void log(String msg) {
> >>  if (LOG)  Log.v(msg);
> >> }
>
> >> - While debugging, LOG is true.  For production, LOG is false.
>
> >> - Throughout the code, I will then log with functions like:
> >> MainApp.log("This is a logged message, variable a="+a);
>
> >> My question is, if I set LOG to false, will the compiler recognize
> >> that the entire log function is useless and not even perform the
> >> string concatenation?  Or, will it perform the string concatenation,
> >> but then immediately disregard the results?  Obviously, I prefer the
> >> former (fewer ops = better), but I don't know how to check for this.
>
> >> Thanks,
> >> jsdf
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to