aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2023-07-27 12:47:28 -0600
committerJon Atack <jon@atack.com>2023-08-24 15:51:22 -0600
commit7d494a48ddf4248ef3b1753b6e7f2eeab3a8ecb7 (patch)
tree7e77360e8751c8cab629cb49da20fdf3d461ff14 /src/rpc/util.h
parentc9273f68f6a17b669890b0b2d38dbcc8b3c39d7b (diff)
refactor: use string_view to pass string literals to Parse{Hash,Hex}
as string_view is optimized to be trivially copiable, and in these use cases we only perform read operations on the passed object. These utility methods are called by quite a few RPCs and tests, as well as by each other. $ git grep "ParseHashV\|ParseHashO\|ParseHexV\|ParseHexO" | wc -l 61
Diffstat (limited to 'src/rpc/util.h')
-rw-r--r--src/rpc/util.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rpc/util.h b/src/rpc/util.h
index 392540ffad..addf9000d0 100644
--- a/src/rpc/util.h
+++ b/src/rpc/util.h
@@ -26,6 +26,7 @@
#include <map>
#include <optional>
#include <string>
+#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
@@ -91,10 +92,10 @@ void RPCTypeCheckObj(const UniValue& o,
* Utilities: convert hex-encoded Values
* (throws error if not hex).
*/
-uint256 ParseHashV(const UniValue& v, std::string strName);
-uint256 ParseHashO(const UniValue& o, std::string strKey);
-std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName);
-std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey);
+uint256 ParseHashV(const UniValue& v, std::string_view name);
+uint256 ParseHashO(const UniValue& o, std::string_view strKey);
+std::vector<unsigned char> ParseHexV(const UniValue& v, std::string_view name);
+std::vector<unsigned char> ParseHexO(const UniValue& o, std::string_view strKey);
/**
* Validate and return a CAmount from a UniValue number or string.