From fa940f41eaffa4b2a28c465a10a4c12d4b8976b8 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 27 Jul 2023 12:17:50 +0200 Subject: Remove unused raw-pointer read helper from univalue --- src/univalue/include/univalue.h | 8 ++++---- src/univalue/lib/univalue_read.cpp | 8 +++++--- src/univalue/test/unitester.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/univalue') diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index 94f80f9c27..acbce25741 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -7,13 +7,15 @@ #define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_H #include +#include #include -#include #include #include #include #include +#include #include +#include #include class UniValue { @@ -94,9 +96,7 @@ public: std::string write(unsigned int prettyIndent = 0, unsigned int indentLevel = 0) const; - bool read(const char *raw, size_t len); - bool read(const char *raw) { return read(raw, strlen(raw)); } - bool read(std::string_view raw) { return read(raw.data(), raw.size()); } + bool read(std::string_view raw); private: UniValue::VType typ; diff --git a/src/univalue/lib/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp index 2f2385383c..40d465f438 100644 --- a/src/univalue/lib/univalue_read.cpp +++ b/src/univalue/lib/univalue_read.cpp @@ -5,10 +5,11 @@ #include #include -#include #include +#include #include #include +#include #include /* @@ -259,7 +260,7 @@ enum expect_bits : unsigned { #define setExpect(bit) (expectMask |= EXP_##bit) #define clearExpect(bit) (expectMask &= ~EXP_##bit) -bool UniValue::read(const char *raw, size_t size) +bool UniValue::read(std::string_view str_in) { clear(); @@ -270,7 +271,8 @@ bool UniValue::read(const char *raw, size_t size) unsigned int consumed; enum jtokentype tok = JTOK_NONE; enum jtokentype last_tok = JTOK_NONE; - const char* end = raw + size; + const char* raw{str_in.data()}; + const char* end{raw + str_in.size()}; do { last_tok = tok; diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp index 6344a5a0ab..d27e647e5c 100644 --- a/src/univalue/test/unitester.cpp +++ b/src/univalue/test/unitester.cpp @@ -153,7 +153,7 @@ void no_nul_test() { char buf[] = "___[1,2,3]___"; UniValue val; - assert(val.read(buf + 3, 7)); + assert(val.read({buf + 3, 7})); } int main (int argc, char *argv[]) -- cgit v1.2.3