aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-09-03 10:31:13 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-09-03 16:06:20 +0200
commitfac973647d69dd14089cee9972e8dfa0074c8a97 (patch)
treeee3ddee65e7fbbebb3e55ae213ac31f4a9d728b2 /src/test
parent9cb9651d92ddb5d92724f6a52440601c7a0bbcf8 (diff)
test: Use string_view for json_tests
This avoids a static constructor of the global std::string, and rules out possibly expensive and implicit copies of the string completely.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/util/json.cpp8
-rw-r--r--src/test/util/json.h8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/test/util/json.cpp b/src/test/util/json.cpp
index ad3c346c84..46a4a9f9a1 100644
--- a/src/test/util/json.cpp
+++ b/src/test/util/json.cpp
@@ -1,15 +1,15 @@
-// Copyright (c) 2023 The Bitcoin Core developers
+// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/util/json.h>
-#include <string>
+#include <univalue.h>
#include <util/check.h>
-#include <univalue.h>
+#include <string_view>
-UniValue read_json(const std::string& jsondata)
+UniValue read_json(std::string_view jsondata)
{
UniValue v;
Assert(v.read(jsondata) && v.isArray());
diff --git a/src/test/util/json.h b/src/test/util/json.h
index 5b1026762e..f6f4e6ab71 100644
--- a/src/test/util/json.h
+++ b/src/test/util/json.h
@@ -1,14 +1,14 @@
-// Copyright (c) 2023 The Bitcoin Core developers
+// Copyright (c) 2023-present The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_UTIL_JSON_H
#define BITCOIN_TEST_UTIL_JSON_H
-#include <string>
-
#include <univalue.h>
-UniValue read_json(const std::string& jsondata);
+#include <string_view>
+
+UniValue read_json(std::string_view jsondata);
#endif // BITCOIN_TEST_UTIL_JSON_H