mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
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.
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user