mirror of
https://github.com/NixOS/nix
synced 2025-06-28 22:01:15 +02:00
* 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. :-)
This commit is contained in:
parent
d2e3a132fe
commit
15801c88fa
10 changed files with 60 additions and 45 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue