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

This commit is contained in:
Stephen Kelly 2015-01-15 23:39:38 +01:00
parent fd0c036c0c
commit 5f69314ea6
5 changed files with 8 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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

View File

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