speedup C dependency scanning even more
Scanning the dependencies for kdelibs/khtml/ (when all files are scanned) is now down to 4.6 s from 6.3 s before this change (without the headerLocationCache it takes about 14 s here). It doesn't really make sense to include the complete include path as part of the key for the map, since the include path will be the same for all files in a project, so it doesn't add anything. Alex
This commit is contained in:
parent
9000b5a4de
commit
8a5ae4c15e
@ -149,10 +149,8 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
|||||||
std::set<cmStdString> dependencies;
|
std::set<cmStdString> dependencies;
|
||||||
std::set<cmStdString> scanned;
|
std::set<cmStdString> scanned;
|
||||||
|
|
||||||
// Use reserve to allocate enough memory for both strings,
|
// Use reserve to allocate enough memory for tempPathStr
|
||||||
// so that during the loops no memory is allocated or freed
|
// so that during the loops no memory is allocated or freed
|
||||||
std::string cacheKey;
|
|
||||||
cacheKey.reserve(4*1024);
|
|
||||||
std::string tempPathStr;
|
std::string tempPathStr;
|
||||||
tempPathStr.reserve(4*1024);
|
tempPathStr.reserve(4*1024);
|
||||||
|
|
||||||
@ -181,22 +179,8 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// With GCC distribution of STL, assigning to a string directly
|
|
||||||
// throws away the internal buffer of the left-hand-side. We
|
|
||||||
// want to keep the pre-allocated buffer so we use C-style
|
|
||||||
// string assignment and then operator+=. We could call
|
|
||||||
// .clear() instead of assigning to an empty string but the
|
|
||||||
// method does not exist on some older compilers.
|
|
||||||
cacheKey = "";
|
|
||||||
cacheKey += current.FileName;
|
|
||||||
|
|
||||||
for(std::vector<std::string>::const_iterator i =
|
|
||||||
this->IncludePath.begin(); i != this->IncludePath.end(); ++i)
|
|
||||||
{
|
|
||||||
cacheKey+=*i;
|
|
||||||
}
|
|
||||||
std::map<cmStdString, cmStdString>::iterator
|
std::map<cmStdString, cmStdString>::iterator
|
||||||
headerLocationIt=this->HeaderLocationCache.find(cacheKey);
|
headerLocationIt=this->HeaderLocationCache.find(current.FileName);
|
||||||
if (headerLocationIt!=this->HeaderLocationCache.end())
|
if (headerLocationIt!=this->HeaderLocationCache.end())
|
||||||
{
|
{
|
||||||
fullName=headerLocationIt->second;
|
fullName=headerLocationIt->second;
|
||||||
@ -214,16 +198,16 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tempPathStr += *i;
|
tempPathStr += *i;
|
||||||
tempPathStr+="/";
|
tempPathStr+="/";
|
||||||
tempPathStr+=current.FileName;
|
tempPathStr+=current.FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for the file in this location.
|
// Look for the file in this location.
|
||||||
if(cmSystemTools::FileExists(tempPathStr.c_str(), true))
|
if(cmSystemTools::FileExists(tempPathStr.c_str(), true))
|
||||||
{
|
{
|
||||||
fullName = tempPathStr;
|
fullName = tempPathStr;
|
||||||
HeaderLocationCache[cacheKey]=fullName;
|
HeaderLocationCache[current.FileName]=fullName;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user