[Pkg-bitcoin-commits] [libunivalue] 11/38: Return const references from getKeys, getValues, get_str
Jonas Smedegaard
dr at jones.dk
Mon Feb 27 01:13:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository libunivalue.
commit 5668ca397bfe4549317d2bcac2d9cb04f795d29c
Author: Wladimir J. van der Laan <laanwj at gmail.com>
Date: Sun Sep 25 19:43:10 2016 +0200
Return const references from getKeys, getValues, get_str
This way a needless copy can be prevented.
---
include/univalue.h | 6 +++---
lib/univalue.cpp | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/univalue.h b/include/univalue.h
index e48b905..e8ce283 100644
--- a/include/univalue.h
+++ b/include/univalue.h
@@ -142,10 +142,10 @@ private:
public:
// Strict type-specific getters, these throw std::runtime_error if the
// value is of unexpected type
- std::vector<std::string> getKeys() const;
- std::vector<UniValue> getValues() const;
+ const std::vector<std::string>& getKeys() const;
+ const std::vector<UniValue>& getValues() const;
bool get_bool() const;
- std::string get_str() const;
+ const std::string& get_str() const;
int get_int() const;
int64_t get_int64() const;
double get_real() const;
diff --git a/lib/univalue.cpp b/lib/univalue.cpp
index 1f8cee6..5a2860c 100644
--- a/lib/univalue.cpp
+++ b/lib/univalue.cpp
@@ -283,14 +283,14 @@ const UniValue& find_value(const UniValue& obj, const std::string& name)
return NullUniValue;
}
-std::vector<std::string> UniValue::getKeys() const
+const std::vector<std::string>& UniValue::getKeys() const
{
if (typ != VOBJ)
throw std::runtime_error("JSON value is not an object as expected");
return keys;
}
-std::vector<UniValue> UniValue::getValues() const
+const std::vector<UniValue>& UniValue::getValues() const
{
if (typ != VOBJ && typ != VARR)
throw std::runtime_error("JSON value is not an object or array as expected");
@@ -304,7 +304,7 @@ bool UniValue::get_bool() const
return getBool();
}
-std::string UniValue::get_str() const
+const std::string& UniValue::get_str() const
{
if (typ != VSTR)
throw std::runtime_error("JSON value is not a string as expected");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bitcoin/libunivalue.git
More information about the Pkg-bitcoin-commits
mailing list