On Sun, Jun 20, 2010 at 4:35 AM, Chris Lercher <[email protected]>wrote:

> Hi,
>
> at the bottom of http://code.google.com/p/gwt-log/wiki/GettingStarted,
> there's an example that shows, when to use if (Log.isDebugEnabled())
> {...}
>
> I would like to know a little bit more about that: In which cases can
> the code be removed for log_level=OFF? I tried the following:
>
> Log.debug("Adding " + list.size() + " items");
>

The answer depends. The GWT compiler might or might not. Looking at the
JavaScript is the sure way to know. But beware of hidden calls, i.e. you
might just see this in your code:
  list.size();

As the compiler gets smarter it will get better and better at eliminating
these.


What is true is that it never hurts to add the if block when in doubt since
the if statement and its contents will be compiled out.



> Looking at the compiled JS, the call to list.size() is removed nicely
> from the output. Can I assume that everything I use inside the
> parentheses always gets removed? In which cases (roughly) can't the
> compiler remove the code anymore?
>
> Thanks
> Chris
>
> --
> You received this message because you are subscribed to the Google Groups
> "gwt-log" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<gwt-log%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/gwt-log?hl=en.
>
>


-- 
Fred Sauer
Developer Advocate
Google Inc.
1600 Amphitheatre Parkway
Mountain View, CA 94043
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"gwt-log" 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/gwt-log?hl=en.

Reply via email to