Convert loops into the commonly used pattern.

This commit is contained in:
Stephen Kelly 2015-01-17 17:47:10 +01:00
parent 0a4e5674ec
commit 7ee56f0399
2 changed files with 25 additions and 32 deletions

View File

@ -25,7 +25,6 @@ bool cmGetCMakePropertyCommand
return false; return false;
} }
std::vector<std::string>::size_type cc;
std::string variable = args[0]; std::string variable = args[0];
std::string output = "NOTFOUND"; std::string output = "NOTFOUND";
@ -35,12 +34,15 @@ bool cmGetCMakePropertyCommand
std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly); std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
if (!vars.empty()) if (!vars.empty())
{ {
output = vars[0]; output = "";
} const char* sep = "";
for ( cc = 1; cc < vars.size(); ++cc ) std::vector<std::string>::size_type cc;
{ for ( cc = 0; cc < vars.size(); ++cc )
output += ";"; {
output += vars[cc]; output += sep;
output += vars[cc];
sep = ";";
}
} }
} }
else if ( args[1] == "MACROS" ) else if ( args[1] == "MACROS" )
@ -54,13 +56,12 @@ bool cmGetCMakePropertyCommand
->GetInstallComponents(); ->GetInstallComponents();
std::set<std::string>::const_iterator compIt; std::set<std::string>::const_iterator compIt;
output = ""; output = "";
const char* sep = "";
for (compIt = components->begin(); compIt != components->end(); ++compIt) for (compIt = components->begin(); compIt != components->end(); ++compIt)
{ {
if (compIt != components->begin()) output += sep;
{
output += ";";
}
output += *compIt; output += *compIt;
sep = ";";
} }
} }
else else

View File

@ -3752,15 +3752,12 @@ void cmMakefile::GetListOfMacros(std::string& macros) const
{ {
StringStringMap::const_iterator it; StringStringMap::const_iterator it;
macros = ""; macros = "";
int cc = 0; const char* sep = "";
for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it ) for ( it = this->MacrosMap.begin(); it != this->MacrosMap.end(); ++it )
{ {
if ( cc > 0 ) macros += sep;
{
macros += ";";
}
macros += it->first; macros += it->first;
cc ++; sep = "";
} }
} }
@ -4205,15 +4202,14 @@ const char *cmMakefile::GetProperty(const std::string& prop,
} }
else if (prop == "LISTFILE_STACK") else if (prop == "LISTFILE_STACK")
{ {
const char* sep = "";
for (std::deque<std::string>::const_iterator for (std::deque<std::string>::const_iterator
i = this->ListFileStack.begin(); i = this->ListFileStack.begin();
i != this->ListFileStack.end(); ++i) i != this->ListFileStack.end(); ++i)
{ {
if (i != this->ListFileStack.begin()) output += sep;
{
output += ";";
}
output += *i; output += *i;
sep = ";";
} }
return output.c_str(); return output.c_str();
} }
@ -4225,13 +4221,12 @@ const char *cmMakefile::GetProperty(const std::string& prop,
cacheonly = 1; cacheonly = 1;
} }
std::vector<std::string> vars = this->GetDefinitions(cacheonly); std::vector<std::string> vars = this->GetDefinitions(cacheonly);
const char* sep = "";
for (unsigned int cc = 0; cc < vars.size(); cc ++ ) for (unsigned int cc = 0; cc < vars.size(); cc ++ )
{ {
if ( cc > 0 ) output += sep;
{
output += ";";
}
output += vars[cc]; output += vars[cc];
sep = ";";
} }
return output.c_str(); return output.c_str();
} }
@ -4247,19 +4242,16 @@ const char *cmMakefile::GetProperty(const std::string& prop,
} }
else if (prop == "LINK_DIRECTORIES") else if (prop == "LINK_DIRECTORIES")
{ {
std::ostringstream str; const char* sep = "";
for (std::vector<std::string>::const_iterator for (std::vector<std::string>::const_iterator
it = this->GetLinkDirectories().begin(); it = this->GetLinkDirectories().begin();
it != this->GetLinkDirectories().end(); it != this->GetLinkDirectories().end();
++ it ) ++ it )
{ {
if ( it != this->GetLinkDirectories().begin()) output += sep;
{ output += *it;
str << ";"; sep = ";";
}
str << it->c_str();
} }
output = str.str();
return output.c_str(); return output.c_str();
} }
else if (prop == "INCLUDE_DIRECTORIES") else if (prop == "INCLUDE_DIRECTORIES")