summaryrefslogtreecommitdiffstats
path: root/Source/cmServerProtocol.cxx
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2017-04-21 17:19:29 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2017-04-26 06:59:56 (GMT)
commita168b4ccc2b479d32455d7bb63c97a9a9d4dee68 (patch)
tree702f7f16592bce165b95c746f495fd78a5e5a13a /Source/cmServerProtocol.cxx
parent1ef22a26c97e2661f0670b5794c47b5339b64da7 (diff)
downloadCMake-a168b4ccc2b479d32455d7bb63c97a9a9d4dee68.zip
CMake-a168b4ccc2b479d32455d7bb63c97a9a9d4dee68.tar.gz
CMake-a168b4ccc2b479d32455d7bb63c97a9a9d4dee68.tar.bz2
cmServerProtocol: avoid copies in range for
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r--Source/cmServerProtocol.cxx29
1 files changed, 13 insertions, 16 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 8227ab7..11ee897 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -50,9 +50,8 @@ std::vector<std::string> getConfigurations(const cmake* cm)
bool hasString(const Json::Value& v, const std::string& s)
{
return !v.isNull() &&
- std::find_if(v.begin(), v.end(), [s](const Json::Value& i) {
- return i.asString() == s;
- }) != v.end();
+ std::any_of(v.begin(), v.end(),
+ [s](const Json::Value& i) { return i.asString() == s; });
}
template <class T>
@@ -493,16 +492,14 @@ cmServerResponse cmServerProtocol1_0::ProcessCache(
if (keys.empty()) {
keys = allKeys;
} else {
- for (auto i : keys) {
- if (std::find_if(allKeys.begin(), allKeys.end(),
- [i](const std::string& j) { return i == j; }) ==
- allKeys.end()) {
+ for (const auto& i : keys) {
+ if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
return request.ReportError("Key \"" + i + "\" not found in cache.");
}
}
}
std::sort(keys.begin(), keys.end());
- for (auto key : keys) {
+ for (const auto& key : keys) {
Json::Value entry = Json::objectValue;
entry[kKEY_KEY] = key;
entry[kTYPE_KEY] =
@@ -511,7 +508,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCache(
Json::Value props = Json::objectValue;
bool haveProperties = false;
- for (auto prop : state->GetCacheEntryPropertyList(key)) {
+ for (const auto& prop : state->GetCacheEntryPropertyList(key)) {
haveProperties = true;
props[prop] = state->GetCacheEntryProperty(key, prop);
}
@@ -598,7 +595,7 @@ bool LanguageData::operator==(const LanguageData& other) const
void LanguageData::SetDefines(const std::set<std::string>& defines)
{
std::vector<std::string> result;
- for (auto i : defines) {
+ for (const auto& i : defines) {
result.push_back(i);
}
std::sort(result.begin(), result.end());
@@ -615,11 +612,11 @@ struct hash<LanguageData>
using std::hash;
size_t result =
hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
- for (auto i : in.IncludePathList) {
+ for (const auto& i : in.IncludePathList) {
result = result ^ (hash<std::string>()(i.first) ^
(i.second ? std::numeric_limits<size_t>::max() : 0));
}
- for (auto i : in.Defines) {
+ for (const auto& i : in.Defines) {
result = result ^ hash<std::string>()(i);
}
result =
@@ -643,7 +640,7 @@ static Json::Value DumpSourceFileGroup(const LanguageData& data,
}
if (!data.IncludePathList.empty()) {
Json::Value includes = Json::arrayValue;
- for (auto i : data.IncludePathList) {
+ for (const auto& i : data.IncludePathList) {
Json::Value tmp = Json::objectValue;
tmp[kPATH_KEY] = i.first;
if (i.second) {
@@ -661,7 +658,7 @@ static Json::Value DumpSourceFileGroup(const LanguageData& data,
result[kIS_GENERATED_KEY] = data.IsGenerated;
Json::Value sourcesValue = Json::arrayValue;
- for (auto i : files) {
+ for (const auto& i : files) {
const std::string relPath =
cmSystemTools::RelativePath(baseDir.c_str(), i.c_str());
sourcesValue.append(relPath.size() < i.size() ? relPath : i);
@@ -819,7 +816,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
std::set<std::string> languages;
target->GetLanguages(languages, config);
std::map<std::string, LanguageData> languageDataMap;
- for (auto lang : languages) {
+ for (const auto& lang : languages) {
LanguageData& ld = languageDataMap[lang];
ld.Language = lang;
lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
@@ -1095,7 +1092,7 @@ cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
kCHECK_SYSTEM_VARS_KEY
};
- for (auto i : boolValues) {
+ for (const auto& i : boolValues) {
if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
return request.ReportError("\"" + i +
"\" must be unset or a bool value.");