diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-09T10·35+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-11-09T10·35+0000 |
commit | 15801c88fad38253b19ac2ea77e7597deab5fd6b (patch) | |
tree | 2dab8ab76792328b6c5376509d6b2e659ad19cf8 /src/libnix/util.cc | |
parent | d2e3a132fe6796b2ac038ccb20e7aa32afc1a85f (diff) |
* 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. :-)
Diffstat (limited to 'src/libnix/util.cc')
-rw-r--r-- | src/libnix/util.cc | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/libnix/util.cc b/src/libnix/util.cc index 016ee991a45c..299a37f6c877 100644 --- a/src/libnix/util.cc +++ b/src/libnix/util.cc @@ -110,7 +110,7 @@ bool pathExists(const Path & path) void deletePath(const Path & path) { - msg(lvlVomit, format("deleting path `%1%'") % path); + printMsg(lvlVomit, format("deleting path `%1%'") % path); struct stat st; if (lstat(path.c_str(), &st)) @@ -194,15 +194,9 @@ Verbosity verbosity = lvlError; static int nestingLevel = 0; -Nest::Nest(Verbosity level, const format & f) +Nest::Nest() { - if (level > verbosity) - nest = false; - else { - msg(level, f); - nest = true; - nestingLevel++; - } + nest = false; } @@ -212,7 +206,17 @@ Nest::~Nest() } -void msg(Verbosity level, const format & f) +void Nest::open(Verbosity level, const format & f) +{ + if (level <= verbosity) { + printMsg_(level, f); + nest = true; + nestingLevel++; + } +} + + +void printMsg_(Verbosity level, const format & f) { if (level > verbosity) return; string spaces; @@ -222,12 +226,6 @@ void msg(Verbosity level, const format & f) } -void debug(const format & f) -{ - msg(lvlDebug, f); -} - - void readFull(int fd, unsigned char * buf, size_t count) { while (count) { |