Merge topic 'consistent-empty'

e876963f Replace '0 == instances.size()' with instances.empty().
44ffb9cd Replace foo.size() pattern with !foo.empty().
8f89f8b1 Replace 'foo.size() != 0' pattern with !foo.empty().
524610f9 Replace 'foo.size() == 0' pattern with foo.empty().
0e14c7ee Replace 'foo.size() > 0' pattern with !foo.empty().
This commit is contained in:
Brad King 2015-08-25 15:13:33 -04:00 committed by CMake Topic Stage
commit cdb9984bff
19 changed files with 41 additions and 41 deletions

View File

@ -191,7 +191,7 @@ int cmCPackIFWGenerator::PackageFiles()
} }
} }
// TODO: set correct name for multipackages // TODO: set correct name for multipackages
if (this->packageFileNames.size() > 0) if (!this->packageFileNames.empty())
{ {
ifwCmd += " " + packageFileNames[0]; ifwCmd += " " + packageFileNames[0];
} }

View File

@ -217,7 +217,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{ {
std::string defaultRef = "WixUI_InstallDir"; std::string defaultRef = "WixUI_InstallDir";
if(this->Components.size()) if(!this->Components.empty())
{ {
defaultRef = "WixUI_FeatureTree"; defaultRef = "WixUI_FeatureTree";
} }
@ -1005,7 +1005,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
shortcut.workingDirectoryId = directoryId; shortcut.workingDirectoryId = directoryId;
shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut); shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut);
if(desktopExecutables.size() && if(!desktopExecutables.empty() &&
std::find(desktopExecutables.begin(), std::find(desktopExecutables.begin(),
desktopExecutables.end(), desktopExecutables.end(),
executableName) executableName)

View File

@ -71,7 +71,7 @@ void cmWIXAccessControlList::CreatePermissionElement(
this->SourceWriter.BeginElement("Permission"); this->SourceWriter.BeginElement("Permission");
this->SourceWriter.AddAttribute("User", user); this->SourceWriter.AddAttribute("User", user);
if(domain.size()) if(!domain.empty())
{ {
this->SourceWriter.AddAttribute("Domain", domain); this->SourceWriter.AddAttribute("Domain", domain);
} }

View File

@ -79,7 +79,7 @@ bool cmWIXPatch::CheckForUnappliedFragments()
fragmentList += "'"; fragmentList += "'";
} }
if(fragmentList.size()) if(!fragmentList.empty())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Some XML patch fragments did not have matching IDs: " << "Some XML patch fragments did not have matching IDs: " <<

View File

@ -128,7 +128,7 @@ void cmWIXSourceWriter::AddAttribute(
void cmWIXSourceWriter::AddAttributeUnlessEmpty( void cmWIXSourceWriter::AddAttributeUnlessEmpty(
std::string const& key, std::string const& value) std::string const& key, std::string const& value)
{ {
if(value.size()) if(!value.empty())
{ {
AddAttribute(key, value); AddAttribute(key, value);
} }

View File

@ -49,7 +49,7 @@ int cmCPackNSISGenerator::PackageFiles()
// TODO: Fix nsis to force out file name // TODO: Fix nsis to force out file name
std::string nsisInFileName = this->FindTemplate("NSIS.template.in"); std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
if ( nsisInFileName.size() == 0 ) if (nsisInFileName.empty())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPack error: Could not find NSIS installer template file." "CPack error: Could not find NSIS installer template file."
@ -58,7 +58,7 @@ int cmCPackNSISGenerator::PackageFiles()
} }
std::string nsisInInstallOptions std::string nsisInInstallOptions
= this->FindTemplate("NSIS.InstallOptions.ini.in"); = this->FindTemplate("NSIS.InstallOptions.ini.in");
if ( nsisInInstallOptions.size() == 0 ) if (nsisInInstallOptions.empty())
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPack error: Could not find NSIS installer options file." "CPack error: Could not find NSIS installer options file."
@ -536,7 +536,7 @@ int cmCPackNSISGenerator::InitializeInternal()
<< ".lnk\"" << std::endl; << ".lnk\"" << std::endl;
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link // if so add a desktop link
if(cpackPackageDesktopLinksVector.size() && if(!cpackPackageDesktopLinksVector.empty() &&
std::find(cpackPackageDesktopLinksVector.begin(), std::find(cpackPackageDesktopLinksVector.begin(),
cpackPackageDesktopLinksVector.end(), cpackPackageDesktopLinksVector.end(),
execName) execName)

View File

@ -498,7 +498,7 @@ int cmCallVisualStudioMacro::CallMacro(
} }
} }
if(0 == instances.size()) if(instances.empty())
{ {
// no instances to call // no instances to call

View File

@ -62,19 +62,19 @@ void cmGlobalMSYSMakefileGenerator
locations.push_back("c:/mingw/bin"); locations.push_back("c:/mingw/bin");
std::string tgcc = cmSystemTools::FindProgram("gcc", locations); std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
std::string gcc = "gcc.exe"; std::string gcc = "gcc.exe";
if(tgcc.size()) if(!tgcc.empty())
{ {
gcc = tgcc; gcc = tgcc;
} }
std::string tgxx = cmSystemTools::FindProgram("g++", locations); std::string tgxx = cmSystemTools::FindProgram("g++", locations);
std::string gxx = "g++.exe"; std::string gxx = "g++.exe";
if(tgxx.size()) if(!tgxx.empty())
{ {
gxx = tgxx; gxx = tgxx;
} }
std::string trc = cmSystemTools::FindProgram("windres", locations); std::string trc = cmSystemTools::FindProgram("windres", locations);
std::string rc = "windres.exe"; std::string rc = "windres.exe";
if(trc.size()) if(!trc.empty())
{ {
rc = trc; rc = trc;
} }

View File

@ -255,7 +255,7 @@ void cmGlobalVisualStudio6Generator
::OutputDSWFile(cmLocalGenerator* root, ::OutputDSWFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) std::vector<cmLocalGenerator*>& generators)
{ {
if(generators.size() == 0) if(generators.empty())
{ {
return; return;
} }

View File

@ -212,7 +212,7 @@ cmGlobalVisualStudio71Generator
{ {
const char* name = di->c_str(); const char* name = di->c_str();
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
if(guid.size() == 0) if(guid.empty())
{ {
std::string m = "Target: "; std::string m = "Target: ";
m += target.GetName(); m += target.GetName();
@ -250,7 +250,7 @@ void cmGlobalVisualStudio71Generator
std::set<std::string>::const_iterator it; std::set<std::string>::const_iterator it;
for(it = depends.begin(); it != depends.end(); ++it) for(it = depends.begin(); it != depends.end(); ++it)
{ {
if(it->size() > 0) if(!it->empty())
{ {
fout << "\t\t{" fout << "\t\t{"
<< this->GetGUID(it->c_str()) << this->GetGUID(it->c_str())

View File

@ -359,7 +359,7 @@ void cmGlobalVisualStudio7Generator
::OutputSLNFile(cmLocalGenerator* root, ::OutputSLNFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators) std::vector<cmLocalGenerator*>& generators)
{ {
if(generators.size() == 0) if(generators.empty())
{ {
return; return;
} }
@ -736,7 +736,7 @@ cmGlobalVisualStudio7Generator
{ {
const char* name = di->c_str(); const char* name = di->c_str();
std::string guid = this->GetGUID(name); std::string guid = this->GetGUID(name);
if(guid.size() == 0) if(guid.empty())
{ {
std::string m = "Target: "; std::string m = "Target: ";
m += target.GetName(); m += target.GetName();

View File

@ -81,7 +81,7 @@ bool cmGlobalVisualStudioGenerator::Compute()
{ {
std::vector<cmLocalGenerator*>& gen = it->second; std::vector<cmLocalGenerator*>& gen = it->second;
// add the ALL_BUILD to the first local generator of each project // add the ALL_BUILD to the first local generator of each project
if(gen.size()) if(!gen.empty())
{ {
// Use no actual command lines so that the target itself is not // Use no actual command lines so that the target itself is not
// considered always out of date. // considered always out of date.
@ -265,7 +265,7 @@ cmGlobalVisualStudioGenerator
{ {
std::vector<std::string> filenames; std::vector<std::string> filenames;
this->GetFilesReplacedDuringGenerate(filenames); this->GetFilesReplacedDuringGenerate(filenames);
if (filenames.size() > 0) if (!filenames.empty())
{ {
// Convert vector to semi-colon delimited string of filenames: // Convert vector to semi-colon delimited string of filenames:
std::string projects; std::string projects;

View File

@ -772,7 +772,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
sf->GetProperty("COMPILE_DEFINITIONS"), true); sf->GetProperty("COMPILE_DEFINITIONS"), true);
if (!flagsBuild.IsEmpty()) if (!flagsBuild.IsEmpty())
{ {
if (flags.size()) if (!flags.empty())
{ {
flags += ' '; flags += ' ';
} }
@ -1874,7 +1874,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{ {
extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS"; extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS";
} }
if(extraLinkOptionsVar.size()) if(!extraLinkOptionsVar.empty())
{ {
this->CurrentLocalGenerator this->CurrentLocalGenerator
->AddConfigVariableFlags(extraLinkOptions, ->AddConfigVariableFlags(extraLinkOptions,
@ -2614,7 +2614,7 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
config->SetComment(configVector[i].c_str()); config->SetComment(configVector[i].c_str());
config->AddAttribute("buildSettings", buildSettings); config->AddAttribute("buildSettings", buildSettings);
} }
if(configVector.size()) if(!configVector.empty())
{ {
configlist->AddAttribute("defaultConfigurationName", configlist->AddAttribute("defaultConfigurationName",
this->CreateString(configVector[0].c_str())); this->CreateString(configVector[0].c_str()));

View File

@ -33,7 +33,7 @@ class cmVS10XMLParser : public cmXMLParser
virtual void StartElement(const std::string& name, const char**) virtual void StartElement(const std::string& name, const char**)
{ {
// once the GUID is found do nothing // once the GUID is found do nothing
if(this->GUID.size()) if(!this->GUID.empty())
{ {
return; return;
} }

View File

@ -984,11 +984,11 @@ void cmLocalVisualStudio6Generator
std::string libMultiLineDebugOptions; std::string libMultiLineDebugOptions;
std::string libMultiLineOptimizedOptions; std::string libMultiLineOptimizedOptions;
if(libPath.size()) if(!libPath.empty())
{ {
std::string lpath = std::string lpath =
this->ConvertToOutputFormat(libPath.c_str(), SHELL); this->ConvertToOutputFormat(libPath.c_str(), SHELL);
if(lpath.size() == 0) if(lpath.empty())
{ {
lpath = "."; lpath = ".";
} }
@ -1017,11 +1017,11 @@ void cmLocalVisualStudio6Generator
libMultiLineOptionsForDebug += " \n"; libMultiLineOptionsForDebug += " \n";
} }
} }
if(exePath.size()) if(!exePath.empty())
{ {
std::string lpath = std::string lpath =
this->ConvertToOutputFormat(exePath.c_str(), SHELL); this->ConvertToOutputFormat(exePath.c_str(), SHELL);
if(lpath.size() == 0) if(lpath.empty())
{ {
lpath = "."; lpath = ".";
} }
@ -1062,7 +1062,7 @@ void cmLocalVisualStudio6Generator
} }
std::string lpath = std::string lpath =
this->ConvertToOutputFormat(path.c_str(), SHELL); this->ConvertToOutputFormat(path.c_str(), SHELL);
if(lpath.size() == 0) if(lpath.empty())
{ {
lpath = "."; lpath = ".";
} }
@ -1452,7 +1452,7 @@ void cmLocalVisualStudio6Generator
#ifdef CM_USE_OLD_VS6 #ifdef CM_USE_OLD_VS6
// Compute link information for the target. // Compute link information for the target.
if(extraLinkOptions.size()) if(!extraLinkOptions.empty())
{ {
libOptions += " "; libOptions += " ";
libOptions += extraLinkOptions; libOptions += extraLinkOptions;
@ -1543,7 +1543,7 @@ void cmLocalVisualStudio6Generator
std::string line; std::string line;
std::string libnameExports; std::string libnameExports;
if(exportSymbol.size()) if(!exportSymbol.empty())
{ {
libnameExports = "/D \""; libnameExports = "/D \"";
libnameExports += exportSymbol; libnameExports += exportSymbol;

View File

@ -2283,7 +2283,7 @@ public:
virtual void StartElement(const std::string& name, const char** atts) virtual void StartElement(const std::string& name, const char** atts)
{ {
// once the GUID is found do nothing // once the GUID is found do nothing
if(this->GUID.size()) if(!this->GUID.empty())
{ {
return; return;
} }
@ -2331,7 +2331,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
cmVS7XMLParser parser; cmVS7XMLParser parser;
parser.ParseFile(path); parser.ParseFile(path);
// if we can not find a GUID then we will generate one later // if we can not find a GUID then we will generate one later
if(parser.GUID.size() == 0) if(parser.GUID.empty())
{ {
return; return;
} }

View File

@ -1656,7 +1656,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
// for the first time we need a new line if there is something // for the first time we need a new line if there is something
// produced here. // produced here.
const char* firstString = ">\n"; const char* firstString = ">\n";
if(objectName.size()) if(!objectName.empty())
{ {
(*this->BuildFileStream ) << firstString; (*this->BuildFileStream ) << firstString;
firstString = ""; firstString = "";
@ -1675,7 +1675,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
defPropName += configUpper; defPropName += configUpper;
if(const char* ccdefs = sf.GetProperty(defPropName.c_str())) if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
{ {
if(configDefines.size()) if(!configDefines.empty())
{ {
configDefines += ";"; configDefines += ";";
} }
@ -2422,7 +2422,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str()); libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
// Remove trailing spaces from libs // Remove trailing spaces from libs
std::string::size_type pos = libs.size()-1; std::string::size_type pos = libs.size()-1;
if(libs.size() != 0) if(!libs.empty())
{ {
while(libs[pos] == ' ') while(libs[pos] == ' ')
{ {
@ -2783,7 +2783,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
std::vector<cmCustomCommand> const& commands, std::vector<cmCustomCommand> const& commands,
std::string const& configName) std::string const& configName)
{ {
if(commands.size() == 0) if(commands.empty())
{ {
return; return;
} }

View File

@ -274,7 +274,7 @@ cmVisualStudioGeneratorOptions
{ {
// if there are configuration specific flags, then // if there are configuration specific flags, then
// use the configuration specific tag for PreprocessorDefinitions // use the configuration specific tag for PreprocessorDefinitions
if(this->Configuration.size()) if(!this->Configuration.empty())
{ {
fout << prefix; fout << prefix;
this->TargetGenerator->WritePlatformConfigTag( this->TargetGenerator->WritePlatformConfigTag(
@ -346,7 +346,7 @@ cmVisualStudioGeneratorOptions
m != this->FlagMap.end(); ++m) m != this->FlagMap.end(); ++m)
{ {
fout << indent; fout << indent;
if(this->Configuration.size()) if(!this->Configuration.empty())
{ {
this->TargetGenerator->WritePlatformConfigTag( this->TargetGenerator->WritePlatformConfigTag(
m->first.c_str(), m->first.c_str(),
@ -398,7 +398,7 @@ cmVisualStudioGeneratorOptions
if(this->Version >= cmGlobalVisualStudioGenerator::VS10) if(this->Version >= cmGlobalVisualStudioGenerator::VS10)
{ {
fout << prefix; fout << prefix;
if(this->Configuration.size()) if(!this->Configuration.empty())
{ {
this->TargetGenerator->WritePlatformConfigTag( this->TargetGenerator->WritePlatformConfigTag(
"AdditionalOptions", "AdditionalOptions",

View File

@ -22,7 +22,7 @@ cmXCode21Object::cmXCode21Object(PBXType ptype, Type type)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmXCode21Object::PrintComment(std::ostream& out) void cmXCode21Object::PrintComment(std::ostream& out)
{ {
if(this->Comment.size() == 0) if(this->Comment.empty())
{ {
cmXCodeObject* n = this->GetObject("name"); cmXCodeObject* n = this->GetObject("name");
if(n) if(n)