[Scummvm-devel] ScummVM binary size comparison

Rafał Rzepecki divided.mind at gmail.com
Thu Nov 13 06:08:59 CET 2008


On 11/12/08, Max Horn <max at quendi.de> wrote:
> == Disable useless debug() and printf() calls ==
> On ports without a console, you usually just drop whatever output
> debug() or printf() are meant to produce (except maybe in debug
> builds, if you can transfer that data of a serial port.
> But if one does so by replacing the body of those functions by
> nothing, the calls still remain in the code, and that costs a lot (as
> the message string then is included, too). We could solve this by
> introducing a new (set of) macro(s), like this:
> #ifdef DISABLE_DEBUG_OUTPUT
> #define SVM_DEBUG(x)	do {} while(0)
> #else
> #define SVM_DEBUG(x)	debug x
> #endif

Another solution would be to replace the declaration

void debug(int level, char *message, ...); // or whatever it is

with

#ifdef HAVE_CONSOLE
void debug(int level, char *message, ...); // or whatever it is
#else
inline void debug(int level, char *message, ...) { }
#endif

I would be terrified to find an otherwise useful compiler that would
not optimize this out trivially. This implies that the code does
essentially the same thing, but it is a drop-in replacement; IMHO it
is also much more elegant.
-- 
Cheers
- Rafał


More information about the Scummvm-devel mailing list