Browse Source

ENH: Slight improvement in genreation time by recording the setting of CMAKE_COLOR_MAKEFILE in an ivar of each local generator at the beginning of generation. This avoids many repeated table lookups.

Brad King 19 years ago
parent
commit
ff41664c6b
2 changed files with 11 additions and 3 deletions
  1. 6 2
      Source/cmLocalUnixMakefileGenerator3.cxx
  2. 5 1
      Source/cmLocalUnixMakefileGenerator3.h

+ 6 - 2
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -48,6 +48,7 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
   this->DefineWindowsNULL = false;
   this->UnixCD = true;
   this->ForceVerboseMakefiles=false;
+  this->ColorMakefile = false;
 }
 
 //----------------------------------------------------------------------------
@@ -75,6 +76,10 @@ void cmLocalUnixMakefileGenerator3::Generate()
   // Setup our configuration variables for this directory.
   this->ConfigureOutputPaths();
 
+  // Record whether color makefiles are enabled to avoid checking many
+  // times later.
+  this->ColorMakefile = this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE");
+
   // Generate the rule files for each target.
   cmTargets& targets = this->Makefile->GetTargets();
   std::string empty;
@@ -860,8 +865,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
   // Choose the color for the text.
   std::string color_name;
 #ifdef CMAKE_BUILD_WITH_CMAKE
-  if(this->GlobalGenerator->GetToolSupportsColor() &&
-     this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE"))
+  if(this->GlobalGenerator->GetToolSupportsColor() && this->ColorMakefile)
     {
     // See cmake::ExecuteEchoColor in cmake.cxx for these options.
     // This color set is readable on both black and white backgrounds.

+ 5 - 1
Source/cmLocalUnixMakefileGenerator3.h

@@ -308,7 +308,11 @@ private:
   //==========================================================================
 
   std::string HomeRelativeOutputPath;
-  
+
+  /* Copy the setting of CMAKE_COLOR_MAKEFILE from the makefile at the
+     beginning of generation to avoid many duplicate lookups.  */
+  bool ColorMakefile;
+
   std::map<cmStdString,std::vector<cmTarget *> > LocalObjectFiles;
 
   /* does the work for each target */