summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-09-19 17:02:12 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2009-09-19 17:02:12 (GMT)
commit864e2670d68324e44db076de68dee8b370fce22c (patch)
treec0d81f1f89f2775b8f738d09f4fa64b9c20bda9e
parentd4cfb77ffe816f71d456dc70ab18efb7eb19d82d (diff)
downloadCMake-864e2670d68324e44db076de68dee8b370fce22c.zip
CMake-864e2670d68324e44db076de68dee8b370fce22c.tar.gz
CMake-864e2670d68324e44db076de68dee8b370fce22c.tar.bz2
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
-rw-r--r--Source/cmDepends.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 2cb1238..40e9730 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -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;
+ }
}
}