From 789267c94903f23d231e16de6ff50a2926dcf8e4 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 11 Apr 2002 17:02:10 -0400 Subject: ENH: speed improvements --- Source/cmFindFileCommand.h | 2 +- Source/cmFindLibraryCommand.h | 2 +- Source/cmFindPathCommand.h | 2 +- Source/cmFindProgramCommand.h | 2 +- Source/cmIncludeCommand.cxx | 18 ++++--- Source/cmListFileCache.cxx | 7 ++- Source/cmMakefile.cxx | 1 - Source/cmSystemTools.cxx | 63 +++-------------------- Tests/Complex/Executable/complex.cxx | 2 +- Tests/ComplexOneConfig/Executable/complex.cxx | 2 +- Tests/ComplexRelativePaths/Executable/complex.cxx | 2 +- 11 files changed, 31 insertions(+), 72 deletions(-) diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h index e957719..f55e32d 100644 --- a/Source/cmFindFileCommand.h +++ b/Source/cmFindFileCommand.h @@ -49,7 +49,7 @@ public: * This determines if the command gets propagated down * to makefiles located in subdirectories. */ - virtual bool IsInherited() { return true; } + virtual bool IsInherited() { return false; } /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index 7c4a75a..ffa9a81 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -49,7 +49,7 @@ public: * This determines if the command gets propagated down * to makefiles located in subdirectories. */ - virtual bool IsInherited() {return true;} + virtual bool IsInherited() {return false;} /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index 273e921d..8241908 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -49,7 +49,7 @@ public: * This determines if the command gets propagated down * to makefiles located in subdirectories. */ - virtual bool IsInherited() {return true;} + virtual bool IsInherited() {return false;} /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h index 13e79ad..ae21338 100644 --- a/Source/cmFindProgramCommand.h +++ b/Source/cmFindProgramCommand.h @@ -49,7 +49,7 @@ public: * This determines if the command gets propagated down * to makefiles located in subdirectories. */ - virtual bool IsInherited() { return true; } + virtual bool IsInherited() { return false; } /** * The name of the command as specified in CMakeList.txt. diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx index 6cda4a5..54308e4 100644 --- a/Source/cmIncludeCommand.cxx +++ b/Source/cmIncludeCommand.cxx @@ -25,19 +25,21 @@ bool cmIncludeCommand::InitialPass(std::vector const& args) this->SetError("called with wrong number of arguments. " "Include only takes one file."); } - bool exists = cmSystemTools::FileExists(args[0].c_str()); - if(args.size() == 2 && args[1] == "OPTIONAL" && !exists) + bool optional = false; + if(args.size() == 2) { - return true; + optional = args[1] == "OPTIONAL"; } - if(!exists) + + bool readit = m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(), + args[0].c_str()); + if(!optional && !readit) { - std::string error = "Include file not found: " + args[0] + "\n"; - this->SetError(error.c_str()); + std::string m = "Could not find include file:"; + m += args[0]; + this->SetError(m.c_str()); return false; } - m_Makefile->ReadListFile( m_Makefile->GetCurrentListFile(), - args[0].c_str()); return true; } diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 2e0020d..fcfd75c 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -77,10 +77,15 @@ cmListFile* cmListFileCache::GetFileCache(const char* path) bool cmListFileCache::CacheFile(const char* path) { + if(!cmSystemTools::FileExists(path)) + { + return false; + } + std::ifstream fin(path); if(!fin) { - cmSystemTools::Error("error can not open file ", path); + cmSystemTools::Error("cmListFileCache: error can not open file ", path); return false; } std::string name; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 5cca930..5a2071c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -323,7 +323,6 @@ bool cmMakefile::ReadListFile(const char* filename, const char* external) cmListFileCache::GetInstance()->GetFileCache(filenametoread); if(!lf) { - cmSystemTools::Error("error can not open file ", filenametoread); return false; } // add this list file to the list of dependencies diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 22acac8..bb0a86b 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -972,61 +972,14 @@ bool cmSystemTools::FilesDiffer(const char* source, { return true; } - const int buffer_length = 4096; - char bufferSource[buffer_length]; - char bufferDest[buffer_length]; - while(finSource && finDestination) - { - if(finSource.getline(bufferSource, buffer_length, '\n') - || finSource.gcount()) - { - if(finDestination.getline(bufferDest, buffer_length, '\n') - || finDestination.gcount()) - { - // both if statements passed - if(finSource.eof()) - { - if(!finDestination.eof()) - { - return true; - } - if(finSource.gcount() != finDestination.gcount()) - { - return true; - } - if(strncmp(bufferSource, bufferDest, finSource.gcount()) != 0) - { - return true; - } - } - else if(finSource.fail()) - { - if(!finDestination.fail()) - { - return true; - } - if(strcmp(bufferSource, bufferDest) != 0) - { - return true; - } - finSource.clear(finSource.rdstate() & ~std::ios::failbit); - finDestination.clear(finDestination.rdstate() & ~std::ios::failbit); - } - else - { - if(strcmp(bufferSource, bufferDest) != 0) - { - return true; - } - } - } - else - { - return true; - } - } - } - return false; + char* buffer1 = new char[statSource.st_size]; + char* buffer2 = new char[statSource.st_size]; + finSource.read(buffer1, statSource.st_size); + finDestination.read(buffer2, statSource.st_size); + int ret = memcmp(buffer1, buffer2, statSource.st_size); + delete [] buffer2; + delete [] buffer1; + return ret != 0; } diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 7afa821..af49dcd 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -635,7 +635,7 @@ int main() #ifndef REGISTRY_TEST_PATH cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined."); #else - if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) + if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) { cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 7afa821..af49dcd 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -635,7 +635,7 @@ int main() #ifndef REGISTRY_TEST_PATH cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined."); #else - if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) + if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) { cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 7afa821..af49dcd 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -635,7 +635,7 @@ int main() #ifndef REGISTRY_TEST_PATH cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not defined."); #else - if(strcmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) + if(stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) { cmFailed("the 'read registry value' function or CONFIGURE_FILE command is broken. REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH); -- cgit v0.12