ENH: performance fixes for network depends

This commit is contained in:
Bill Hoffman 2003-07-28 18:12:23 -04:00
parent 3d27a6a391
commit 2ba1c0ab06
3 changed files with 44 additions and 9 deletions

View File

@ -1904,8 +1904,11 @@ void cmLocalUnixMakefileGenerator::OutputCheckDepends(std::ostream& fout)
(*source)->GetDepends().begin();
dep != (*source)->GetDepends().end(); ++dep)
{
std::string dependfile =
cmSystemTools::ConvertToOutputPath(cmSystemTools::CollapseFullPath(dep->c_str()).c_str());
// do not call CollapseFullPath on dep here, because it already
// has been done because m_FullPath on cmDependInformation
// always is it called. If it is called here, network builds are
// very slow because of the number of stats
std::string dependfile = cmSystemTools::ConvertToOutputPath(dep->c_str());
// use the lower path function to create uniqe names
std::string lowerpath = this->LowerCasePath(dependfile.c_str());
if(emittedLowerPath.insert(lowerpath).second)

View File

@ -230,10 +230,7 @@ void cmMakeDepend::DependWalk(cmDependInformation* info)
void cmMakeDepend::AddDependency(cmDependInformation* info, const char* file)
{
cmDependInformation* dependInfo =
this->GetDependInformation(file,
cmSystemTools::GetFilenamePath(
cmSystemTools::CollapseFullPath(
info->m_FullPath.c_str())).c_str());
this->GetDependInformation(file, info->m_PathOnly.c_str());
this->GenerateDependInformation(dependInfo);
info->AddDependencies(dependInfo);
}
@ -257,6 +254,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file,
// Didn't find an instance. Create a new one and save it.
cmDependInformation* info = new cmDependInformation;
info->m_FullPath = fullPath;
info->m_PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str());
info->m_IncludeName = file;
m_DependInformationMap[fullPath] = info;
return info;
@ -291,9 +289,31 @@ void cmMakeDepend::GenerateMakefileDependencies()
// find the full path to fname by searching the m_IncludeDirectories array
std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
{
DirectoryToFileToPathMap::iterator m;
if(extraPath)
{
m = m_DirectoryToFileToPathMap.find(extraPath);
}
else
{
m = m_DirectoryToFileToPathMap.find("");
}
if(m != m_DirectoryToFileToPathMap.end())
{
FileToPathMap& map = m->second;
FileToPathMap::iterator p = map.find(fname);
if(p != map.end())
{
return p->second;
}
}
if(cmSystemTools::FileExists(fname))
{
return std::string(cmSystemTools::CollapseFullPath(fname));
std::string fp = cmSystemTools::CollapseFullPath(fname);
m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
return fp;
}
for(std::vector<std::string>::iterator i = m_IncludeDirectories.begin();
@ -307,7 +327,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
path = path + fname;
if(cmSystemTools::FileExists(path.c_str()))
{
return cmSystemTools::CollapseFullPath(path.c_str());
std::string fp = cmSystemTools::CollapseFullPath(path.c_str());
m_DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
return fp;
}
}
@ -321,7 +343,9 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
path = path + fname;
if(cmSystemTools::FileExists(path.c_str()))
{
return cmSystemTools::CollapseFullPath(path.c_str());
std::string fp = cmSystemTools::CollapseFullPath(path.c_str());
m_DirectoryToFileToPathMap[extraPath][fname] = fp;
return fp;
}
}

View File

@ -60,6 +60,11 @@ public:
*/
std::string m_FullPath;
/**
* Full path not including file name.
*/
std::string m_PathOnly;
/**
* Name used to #include this file.
*/
@ -154,8 +159,11 @@ protected:
cmsys::RegularExpression m_IncludeFileRegularExpression;
cmsys::RegularExpression m_ComplainFileRegularExpression;
std::vector<std::string> m_IncludeDirectories;
typedef std::map<cmStdString, cmStdString> FileToPathMap;
typedef std::map<cmStdString, FileToPathMap> DirectoryToFileToPathMap;
typedef std::map<cmStdString, cmDependInformation*> DependInformationMap;
DependInformationMap m_DependInformationMap;
DirectoryToFileToPathMap m_DirectoryToFileToPathMap;
};
#endif