Skip to content
Snippets Groups Projects
Commit 864e2670 authored by Alexander Neundorf's avatar Alexander Neundorf
Browse files

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
parent d4cfb77f
No related branches found
No related tags found
No related merge requests found
......@@ -152,6 +152,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
// or newer than the depender then dependencies should be
// regenerated.
bool okay = true;
bool dependerExists = false;
while(internalDepends.getline(this->Dependee, this->MaxPath))
{
if ( this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
......@@ -168,6 +169,11 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
if ( this->Dependee[0] != ' ' )
{
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;
}
/*
......@@ -198,7 +204,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
cmSystemTools::Stdout(msg.str().c_str());
}
}
else if(cmSystemTools::FileExists(depender))
else if(dependerExists)
{
// The dependee and depender both exist. Compare file times.
int result = 0;
......@@ -225,7 +231,11 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends)
okay = false;
// Remove the depender to be sure it is rebuilt.
cmSystemTools::RemoveFile(depender);
if (dependerExists)
{
cmSystemTools::RemoveFile(depender);
dependerExists = false;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment