Pārlūkot izejas kodu

Merge topic 'use-member-insert'

fa889c4d cmakemain: Initialize vector content with iterators directly.
8211010c cmakemain: Use member insert in command line handling code.
b5422573 cmListCommand: Replace loop with member algorithm.
92a37f92 Convert raw loops to set member insert.
aac44e71 Convert raw loops to vector member insert.
Brad King 11 gadi atpakaļ
vecāks
revīzija
a6bbbd0f4a

+ 2 - 5
Source/cmComputeLinkDepends.cxx

@@ -676,11 +676,8 @@ void cmComputeLinkDepends::InferDependencies()
       }
 
     // Add the inferred dependencies to the graph.
-    for(DependSet::const_iterator j = common.begin(); j != common.end(); ++j)
-      {
-      int dependee_index = *j;
-      this->EntryConstraintGraph[depender_index].push_back(dependee_index);
-      }
+    cmGraphEdgeList& edges = this->EntryConstraintGraph[depender_index];
+    edges.insert(edges.end(), common.begin(), common.end());
     }
 }
 

+ 2 - 6
Source/cmGeneratorExpression.cxx

@@ -98,12 +98,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
     {
     this->Output += (*it)->Evaluate(&context, dagChecker);
 
-    for(std::set<std::string>::const_iterator
-          p = context.SeenTargetProperties.begin();
-          p != context.SeenTargetProperties.end(); ++p)
-      {
-      this->SeenTargetProperties.insert(*p);
-      }
+    this->SeenTargetProperties.insert(context.SeenTargetProperties.begin(),
+                                      context.SeenTargetProperties.end());
     if (context.HadError)
       {
       this->Output = "";

+ 3 - 7
Source/cmListCommand.cxx

@@ -345,13 +345,9 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
       return false;
       }
     }
-  size_t cc;
-  size_t cnt = 0;
-  for ( cc = 3; cc < args.size(); ++ cc )
-    {
-    varArgsExpanded.insert(varArgsExpanded.begin()+item+cnt, args[cc]);
-    cnt ++;
-    }
+
+  varArgsExpanded.insert(varArgsExpanded.begin()+item,
+                         args.begin() + 3, args.end());
 
   std::string value = cmJoin(varArgsExpanded, ";");
   this->Makefile->AddDefinition(listName, value.c_str());

+ 1 - 4
Source/cmLoadCacheCommand.cxx

@@ -110,10 +110,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
 
   // Prepare the table of variables to read.
   this->Prefix = args[2];
-  for(unsigned int i=3; i < args.size(); ++i)
-    {
-    this->VariablesToRead.insert(args[i]);
-    }
+  this->VariablesToRead.insert(args.begin() + 3, args.end());
 
   // Read the cache file.
   cmsys::ifstream fin(cacheFile.c_str());

+ 2 - 5
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -738,11 +738,8 @@ cmLocalUnixMakefileGenerator3
   // Add the output to the local help if requested.
   if(in_help)
     {
-    for (std::vector<std::string>::const_iterator i = outputs.begin();
-         i != outputs.end(); ++i)
-      {
-      this->LocalHelp.push_back(*i);
-      }
+    this->LocalHelp.insert(this->LocalHelp.end(),
+                           outputs.begin(), outputs.end());
     }
 }
 

+ 3 - 9
Source/cmakemain.cxx

@@ -96,11 +96,9 @@ static const char * cmDocumentationOptions[][2] =
 static int do_command(int ac, char const* const* av)
 {
   std::vector<std::string> args;
+  args.reserve(ac - 1);
   args.push_back(av[0]);
-  for(int i = 2; i < ac; ++i)
-    {
-    args.push_back(av[i]);
-    }
+  args.insert(args.end(), av + 2, av + ac);
   return cmcmd::ExecuteCMakeCommand(args);
 }
 
@@ -221,11 +219,7 @@ int do_cmake(int ac, char const* const* av)
 
     // the command line args are processed here so that you can do
     // -DCMAKE_MODULE_PATH=/some/path and have this value accessible here
-    std::vector<std::string> args;
-    for(int i =0; i < ac; ++i)
-      {
-      args.push_back(av[i]);
-      }
+    std::vector<std::string> args(av, av + ac);
     hcm.SetCacheArgs(args);
 
     std::vector<cmDocumentationEntry> generators;