mirror of
https://github.com/NixOS/nix
synced 2025-06-27 21:01:16 +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
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue