From 15801c88fad38253b19ac2ea77e7597deab5fd6b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 9 Nov 2003 10:35:45 +0000 Subject: * Turned the msg() and debug() functions into macros, since they turned out to be a huge performance bottleneck (the text to printed would always be evaluated, even when it was above the verbosity level). This reduces fix-ng execution time by over 50%. gprof(1) is very useful. :-) --- src/libnix/util.hh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/libnix/util.hh') diff --git a/src/libnix/util.hh b/src/libnix/util.hh index 02a9b7fcb8..e6b600eff8 100644 --- a/src/libnix/util.hh +++ b/src/libnix/util.hh @@ -101,12 +101,27 @@ class Nest private: bool nest; public: - Nest(Verbosity level, const format & f); + Nest(); ~Nest(); + void open(Verbosity level, const format & f); }; -void msg(Verbosity level, const format & f); -void debug(const format & f); /* short-hand for msg(lvlDebug, ...) */ +void printMsg_(Verbosity level, const format & f); + +#define startNest(varName, level, f) \ + Nest varName; \ + if (level <= verbosity) { \ + varName.open(level, (f)); \ + } + +#define printMsg(level, f) \ + do { \ + if (level <= verbosity) { \ + printMsg_(level, (f)); \ + } \ + } while (0) + +#define debug(f) printMsg(lvlDebug, f) /* Wrappers arount read()/write() that read/write exactly the -- cgit 1.4.1