浏览代码

Replace foo.length() pattern with !foo.empty().

Stephen Kelly 11 年之前
父节点
当前提交
5f69314ea6

+ 1 - 1
Source/cmBuildNameCommand.cxx

@@ -50,7 +50,7 @@ bool cmBuildNameCommand
     {
     buildname = "";
     cmSystemTools::RunSingleCommand("uname -a", &buildname);
-    if(buildname.length())
+    if(!buildname.empty())
       {
       std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
       cmsys::RegularExpression reg( RegExp.c_str() );

+ 2 - 2
Source/cmDocumentationFormatter.cxx

@@ -46,7 +46,7 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
         preformatted.append(1, '\n');
         }
       }
-    if(preformatted.length())
+    if(!preformatted.empty())
       {
       this->PrintPreformatted(os, preformatted.c_str());
       }
@@ -62,7 +62,7 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
       ++ptr;
       paragraph.append(1, '\n');
       }
-    if(paragraph.length())
+    if(!paragraph.empty())
       {
       this->PrintParagraph(os, paragraph.c_str());
       }

+ 2 - 2
Source/cmLoadCacheCommand.cxx

@@ -160,7 +160,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
         }
       }
     }
-  if(line.length())
+  if(!line.empty())
     {
     // Partial last line.
     this->CheckLine(line.c_str());
@@ -184,7 +184,7 @@ void cmLoadCacheCommand::CheckLine(const char* line)
       // This was requested.  Set this variable locally with the given
       // prefix.
       var = this->Prefix + var;
-      if(value.length())
+      if(!value.empty())
         {
         this->Makefile->AddDefinition(var, value.c_str());
         }

+ 1 - 1
Source/cmLocalGenerator.cxx

@@ -335,7 +335,7 @@ void cmLocalGenerator::GenerateTestFiles()
     {
     (*gi)->Generate(fout, config, configurationTypes);
     }
-  if ( this->Children.size())
+  if (!this->Children.empty())
     {
     size_t i;
     for(i = 0; i < this->Children.size(); ++i)

+ 2 - 2
Source/cmSiteNameCommand.cxx

@@ -66,7 +66,7 @@ bool cmSiteNameCommand
       &host, 0, 0, cmSystemTools::OUTPUT_NONE);
 
     // got the hostname
-    if (host.length())
+    if (!host.empty())
       {
       // remove any white space from the host name
       std::string hostRegExp = "[ \t\n\r]*([^\t\n\r ]*)[ \t\n\r]*";
@@ -77,7 +77,7 @@ bool cmSiteNameCommand
         host = hostReg.match(1);
         }
 
-      if(host.length())
+      if(!host.empty())
         {
         siteName = host;
         }