From 3e7d97d45d167ddab5ebef6a6fd936df3441c4c9 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 30 Sep 2012 10:57:59 +0200 Subject: [PATCH] cmDependsC: remove code duplication This patch reduces a bit code duplication by changing the way how the case that we already have valid dependencies for a file is handled. Instead of having the code for writing the depend-files twice, we now fill the existing dependencies into the same set and then write it out once at the end of cmDependsC::WriteDependencies() Alex Inspired-by: Michael Wild --- Source/cmDependsC.cxx | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 44841a900..b76042988 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -113,32 +113,26 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, return false; } + std::set dependencies; + bool haveDeps = false; + if (this->ValidDeps != 0) { std::map::const_iterator tmpIt = this->ValidDeps->find(obj); if (tmpIt!= this->ValidDeps->end()) { - // Write the dependencies to the output stream. Makefile rules - // written by the original local generator for this directory - // convert the dependencies to paths relative to the home output - // directory. We must do the same here. - internalDepends << obj << std::endl; for(DependencyVector::const_iterator i=tmpIt->second.begin(); i != tmpIt->second.end(); ++i) { - makeDepends << obj << ": " << - this->LocalGenerator->Convert(i->c_str(), - cmLocalGenerator::HOME_OUTPUT, - cmLocalGenerator::MAKEFILE) - << std::endl; - internalDepends << " " << i->c_str() << std::endl; + dependencies.insert(*i); } - makeDepends << std::endl; - return true; + haveDeps = true; } } + if (!haveDeps) + { // Walk the dependency graph starting with the source file. bool first = true; UnscannedEntry root; @@ -146,7 +140,6 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, this->Unscanned.push(root); this->Encountered.clear(); this->Encountered.insert(src); - std::set dependencies; std::set scanned; // Use reserve to allocate enough memory for tempPathStr @@ -269,6 +262,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, first = false; } + } // Write the dependencies to the output stream. Makefile rules // written by the original local generator for this directory