erebor/asciidoctor — pull request #75 by mojavelinux (2013-01-14 07:04:13+00:00)
Title: Remove impact of debug statements on performance

This patch may be controversial, but the benefit to performance cannot be ignored. I've measured a 0.15 sec improvement in rendering the AsciiDoc User Guide with this patch applied (from 0.92 sec to 0.77 sec). That's a huge boost.

The debug statements are sub-optimal atm because they interpolate the strings (hence performing potentially costly method invocations) before passing the string to the debug method. A better approach is to push the strings into a block and have the debug method yield the block if debug is enabled.

I've moved all the debug statements into the block argument of the debug method. I've also removed some statements I find to be unnecessary now that the library is more mature (and we have 500+ tests to use for more fine-grained debugging). I'd really like to remove even more of the debug statements.

IMO, debug statements should be a way to report unexpected or behavior or misconfiguration that isn't consider an warning or error to the user. I think variable dumps are best performed by a debugger or a test case. We want to remove any delay we possibly can from the production code.

I have my fingers crossed that you agree (or at least are willing to agree in the name of the performance boost).