On Tue, May 14, 2013 at 2:36 AM, sebb <seb...@gmail.com> wrote:
> The private debug method requires an array of Objects to be passed to
> System.out.format.
>
> Any primitive parameters will be autoboxed.
>
> However, the boxing will be performed regardless of whether DEBUG is
> true or not.
> This is a bit wasteful as DEBUG is false by default.
>
> It may be better to inline the debug method calls.


Autoboxing into Object varargs which are never used is still cheaper
than conversions and concatenations into a single String that's never
used, which is why slf4j and log4j2 provide it. But either way, a good
compiler should be able to inline debug(), then eliminate the dead
logging code because private static final boolean DEBUG is hardcoded
to false, then optimize all the variables and expressions out of
existence (since they never get read). Even if Hotspot doesn't
optimize that well (and I think it does since assert() supposedly
costs 0 when "-ea" is absent), the performance-critical path of
decompressing file contents doesn't log.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to