mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user