Get rid of push_back in favor of emplace_back
Change-Id: I4a0096441ed725eb21e42eb9cc17a173929e3788
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index 0d8a606..8a41279 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -336,7 +336,7 @@
where.pop_back();
}
} else {
- where.push_back(what);
+ where.emplace_back(what);
}
}
}
diff --git a/src/grammars.hpp b/src/grammars.hpp
index 478e49f..742115b 100644
--- a/src/grammars.hpp
+++ b/src/grammars.hpp
@@ -211,7 +211,7 @@
parserContext.m_tmpListPath = parserContext.currentDataPath();
parserContext.m_tmpListPath.m_nodes.pop_back();
auto list = list_{std::get<listElement_>(attr.m_source.m_nodes.back().m_suffix).m_name};
- parserContext.m_tmpListPath.m_nodes.push_back(dataNode_{attr.m_source.m_nodes.back().m_prefix, list});
+ parserContext.m_tmpListPath.m_nodes.emplace_back(attr.m_source.m_nodes.back().m_prefix, list);
res = (space_separator >> listSuffix).parse(begin, end, ctx, rctx, listInstance);
if (res) {
diff --git a/src/libyang_utils.cpp b/src/libyang_utils.cpp
index a7dd682..756f88c 100644
--- a/src/libyang_utils.cpp
+++ b/src/libyang_utils.cpp
@@ -68,7 +68,7 @@
}
}
if (it->schema()->nodetype() == LYS_LIST) {
- res.push_back({stripXPathPrefix(it->path()), special_{SpecialValue::List}});
+ res.emplace_back(stripXPathPrefix(it->path()), special_{SpecialValue::List});
}
if (it->schema()->nodetype() == LYS_LEAF || it->schema()->nodetype() == LYS_LEAFLIST) {
libyang::Data_Node_Leaf_List leaf(it);
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index ecdece0..689b2b5 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -169,7 +169,7 @@
for (auto it : set->data()) {
if (it->schema()->nodetype() == LYS_LEAF) {
libyang::Data_Node_Leaf_List leaf(it);
- res.push_back(leaf.value_str());
+ res.emplace_back(leaf.value_str());
}
}
return res;
@@ -210,7 +210,7 @@
auto leafSchema = libyang::Schema_Node_Leaf{leafData.schema()};
instanceRes.insert({ leafSchema.name(), leafValueFromValue(leafData.value(), leafSchema.type()->base())});
}
- res.push_back(instanceRes);
+ res.emplace_back(instanceRes);
}
return res;
diff --git a/src/parser_context.cpp b/src/parser_context.cpp
index 17f6604..b50a248 100644
--- a/src/parser_context.cpp
+++ b/src/parser_context.cpp
@@ -52,7 +52,7 @@
m_curPath = dataPathToSchemaPath(boost::get<dataPath_>(m_curPath));
}
- boost::get<schemaPath_>(m_curPath).m_nodes.push_back(node);
+ boost::get<schemaPath_>(m_curPath).m_nodes.emplace_back(node);
}
void ParserContext::resetPath()
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index 39e2797..9fa3db1 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -178,7 +178,7 @@
if (std::holds_alternative<listElement_>(attr.m_suffix)) {
parserContext.m_tmpListPath = parserContext.currentDataPath();
auto tmpList = list_{std::get<listElement_>(attr.m_suffix).m_name};
- parserContext.m_tmpListPath.m_nodes.push_back(dataNode_{attr.m_prefix, tmpList});
+ parserContext.m_tmpListPath.m_nodes.emplace_back(attr.m_prefix, tmpList);
res = listSuffix.parse(begin, end, ctx, rctx, std::get<listElement_>(attr.m_suffix).m_keys);
@@ -284,7 +284,7 @@
dataNode_ attrNodeList;
res = incompleteDataNode<COMPLETION_MODE>{m_filterFunction}.parse(begin, end, ctx, rctx, attrNodeList);
if (res) {
- attrData.m_nodes.push_back(attrNodeList);
+ attrData.m_nodes.emplace_back(attrNodeList);
// If the trailing slash matches, no more nodes are parsed.
// That means no more completion. So, I generate them
// manually.
diff --git a/src/sysrepo_access.cpp b/src/sysrepo_access.cpp
index 61ff560..17c86a0 100644
--- a/src/sysrepo_access.cpp
+++ b/src/sysrepo_access.cpp
@@ -197,15 +197,15 @@
for (unsigned int i = 0; i < items->val_cnt(); i++) {
auto value = leafValueFromVal(items->val(i));
if (m_schema->nodeType(items->val(i)->xpath()) == yang::NodeTypes::LeafList) {
- res.push_back({items->val(i)->xpath(), special_{SpecialValue::LeafList}});
+ res.emplace_back(items->val(i)->xpath(), special_{SpecialValue::LeafList});
std::string leafListPath = items->val(i)->xpath();
while (i < items->val_cnt() && leafListPath == items->val(i)->xpath()) {
auto leafListValue = leafDataToString(leafValueFromVal(items->val(i)));
- res.push_back({items->val(i)->xpath() + "[.="s + escapeListKeyString(leafListValue) + "]", leafListValue});
+ res.emplace_back(items->val(i)->xpath() + "[.="s + escapeListKeyString(leafListValue) + "]", leafListValue);
i++;
}
} else {
- res.push_back({items->val(i)->xpath(), value});
+ res.emplace_back(items->val(i)->xpath(), value);
}
}
};
@@ -315,7 +315,7 @@
Tree res;
for (size_t i = 0; i < output->val_cnt(); ++i) {
const auto& v = output->val(i);
- res.push_back({std::string(v->xpath()).substr(joinPaths(path, "/").size()), leafValueFromVal(v)});
+ res.emplace_back(std::string(v->xpath()).substr(joinPaths(path, "/").size()), leafValueFromVal(v));
}
return res;
}
@@ -354,7 +354,7 @@
}
for (unsigned int i = 0; i < schemas->schema_cnt(); i++) {
auto schema = schemas->schema(i);
- res.push_back(schema);
+ res.emplace_back(schema);
}
return res;
}
@@ -427,7 +427,7 @@
auto leaf = libyang::Data_Node_Leaf_List{*(vec.begin())};
instanceRes.emplace(key->name(), leafValueFromValue(leaf.value(), leaf.leaf_type()->base()));
}
- res.push_back(instanceRes);
+ res.emplace_back(instanceRes);
}
return res;
diff --git a/src/yang_access.cpp b/src/yang_access.cpp
index d5c0ade..79d1c08 100644
--- a/src/yang_access.cpp
+++ b/src/yang_access.cpp
@@ -260,7 +260,7 @@
}
}
}
- res.push_back(instance);
+ res.emplace_back(instance);
}
return res;
}
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 4b65e13..9e63348 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -248,7 +248,7 @@
{
auto resUnion = yang::Union{};
for (auto unionType : type->info()->uni()->types()) {
- resUnion.m_unionTypes.push_back(resolveType(unionType));
+ resUnion.m_unionTypes.emplace_back(resolveType(unionType));
}
resType.emplace<yang::Union>(std::move(resUnion));
break;