aboutsummaryrefslogtreecommitdiff
path: root/src/univalue
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-08-19 11:38:56 +0200
committerMacroFake <falke.marco@gmail.com>2022-08-20 09:32:53 +0200
commitfaad673716cfbad1e715f1bdf8ac00938a055aea (patch)
treefe1134e201b198a4ae2ee1483e0ac13b6a4ccbfa /src/univalue
parentc73c8d53fe27956faacb3e8ca0e94adf071de6ec (diff)
Fix issues when calling std::move(const&)
Diffstat (limited to 'src/univalue')
-rw-r--r--src/univalue/include/univalue.h8
-rw-r--r--src/univalue/lib/univalue.cpp20
2 files changed, 14 insertions, 14 deletions
diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h
index 8ba6fd5425..ccaf56a271 100644
--- a/src/univalue/include/univalue.h
+++ b/src/univalue/include/univalue.h
@@ -80,14 +80,14 @@ public:
bool isArray() const { return (typ == VARR); }
bool isObject() const { return (typ == VOBJ); }
- void push_back(const UniValue& val);
+ void push_back(UniValue val);
void push_backV(const std::vector<UniValue>& vec);
template <class It>
void push_backV(It first, It last);
- void __pushKV(const std::string& key, const UniValue& val);
- void pushKV(const std::string& key, const UniValue& val);
- void pushKVs(const UniValue& obj);
+ void __pushKV(std::string key, UniValue val);
+ void pushKV(std::string key, UniValue val);
+ void pushKVs(UniValue obj);
std::string write(unsigned int prettyIndent = 0,
unsigned int indentLevel = 0) const;
diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp
index 55e777b8ae..12a434dd0e 100644
--- a/src/univalue/lib/univalue.cpp
+++ b/src/univalue/lib/univalue.cpp
@@ -101,11 +101,11 @@ void UniValue::setObject()
typ = VOBJ;
}
-void UniValue::push_back(const UniValue& val_)
+void UniValue::push_back(UniValue val)
{
checkType(VARR);
- values.push_back(val_);
+ values.push_back(std::move(val));
}
void UniValue::push_backV(const std::vector<UniValue>& vec)
@@ -115,32 +115,32 @@ void UniValue::push_backV(const std::vector<UniValue>& vec)
values.insert(values.end(), vec.begin(), vec.end());
}
-void UniValue::__pushKV(const std::string& key, const UniValue& val_)
+void UniValue::__pushKV(std::string key, UniValue val)
{
checkType(VOBJ);
- keys.push_back(key);
- values.push_back(val_);
+ keys.push_back(std::move(key));
+ values.push_back(std::move(val));
}
-void UniValue::pushKV(const std::string& key, const UniValue& val_)
+void UniValue::pushKV(std::string key, UniValue val)
{
checkType(VOBJ);
size_t idx;
if (findKey(key, idx))
- values[idx] = val_;
+ values[idx] = std::move(val);
else
- __pushKV(key, val_);
+ __pushKV(std::move(key), std::move(val));
}
-void UniValue::pushKVs(const UniValue& obj)
+void UniValue::pushKVs(UniValue obj)
{
checkType(VOBJ);
obj.checkType(VOBJ);
for (size_t i = 0; i < obj.keys.size(); i++)
- __pushKV(obj.keys[i], obj.values.at(i));
+ __pushKV(std::move(obj.keys.at(i)), std::move(obj.values.at(i)));
}
void UniValue::getObjMap(std::map<std::string,UniValue>& kv) const