Minor optimization in dependency checking.
When reading the depend.internal file, check only once for every depender whether it exists, instead of repeatedly in a loop for each dependee. Within that function it can only change of the depender is removed. This is taken care of. This reduces the number of access() calls in kdelibs/khtml from 180000 to 90000 (i.e. 50%), and reduces the time for that (without the actual scanning) from 0.3 s to 0.21 s on my system. Alex
This commit is contained in:
parent
d4cfb77ffe
commit
864e2670d6
|
@ -152,6 +152,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
|
||||||
// or newer than the depender then dependencies should be
|
// or newer than the depender then dependencies should be
|
||||||
// regenerated.
|
// regenerated.
|
||||||
bool okay = true;
|
bool okay = true;
|
||||||
|
bool dependerExists = false;
|
||||||
while(internalDepends.getline(this->Dependee, this->MaxPath))
|
while(internalDepends.getline(this->Dependee, this->MaxPath))
|
||||||
{
|
{
|
||||||
if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
|
if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
|
||||||
|
@ -168,6 +169,11 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
|
||||||
if ( this->Dependee[0] != ' ' )
|
if ( this->Dependee[0] != ' ' )
|
||||||
{
|
{
|
||||||
memcpy(this->Depender, this->Dependee, len+1);
|
memcpy(this->Depender, this->Dependee, len+1);
|
||||||
|
// Calling FileExists() for the depender here saves in many cases 50%
|
||||||
|
// of the calls to FileExists() further down in the loop. E.g. for
|
||||||
|
// kdelibs/khtml this reduces the number of calls from 184k down to 92k,
|
||||||
|
// or the time for cmake -E cmake_depends from 0.3 s down to 0.21 s.
|
||||||
|
dependerExists = cmSystemTools::FileExists(this->Depender);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -198,7 +204,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
|
||||||
cmSystemTools::Stdout(msg.str().c_str());
|
cmSystemTools::Stdout(msg.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(cmSystemTools::FileExists(depender))
|
else if(dependerExists)
|
||||||
{
|
{
|
||||||
// The dependee and depender both exist. Compare file times.
|
// The dependee and depender both exist. Compare file times.
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -225,7 +231,11 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
|
||||||
okay = false;
|
okay = false;
|
||||||
|
|
||||||
// Remove the depender to be sure it is rebuilt.
|
// Remove the depender to be sure it is rebuilt.
|
||||||
cmSystemTools::RemoveFile(depender);
|
if (dependerExists)
|
||||||
|
{
|
||||||
|
cmSystemTools::RemoveFile(depender);
|
||||||
|
dependerExists = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue