mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
Use std::string_view
This commit is contained in:
@@ -231,4 +231,11 @@ makeSlice(std::basic_string<char, Traits, Alloc> const& s)
|
||||
return Slice(s.data(), s.size());
|
||||
}
|
||||
|
||||
template <class Traits>
|
||||
Slice
|
||||
makeSlice(std::basic_string_view<char, Traits> const& s)
|
||||
{
|
||||
return Slice(s.data(), s.size());
|
||||
}
|
||||
|
||||
} // namespace xrpl
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
namespace xrpl {
|
||||
@@ -131,16 +132,16 @@ private:
|
||||
processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData& data);
|
||||
|
||||
bool
|
||||
takeHeader(std::string const& data);
|
||||
takeHeader(std::string_view data);
|
||||
|
||||
void
|
||||
receiveNode(protocol::TMLedgerData& packet, SHAMapAddNode& san);
|
||||
|
||||
bool
|
||||
takeTxRootNode(std::string const& data, SHAMapAddNode& san);
|
||||
takeTxRootNode(std::string_view data, SHAMapAddNode& san);
|
||||
|
||||
bool
|
||||
takeAsRootNode(std::string const& data, SHAMapAddNode& san);
|
||||
takeAsRootNode(std::string_view data, SHAMapAddNode& san);
|
||||
|
||||
std::vector<uint256>
|
||||
neededTxHashes(int max, SHAMapSyncFilter* filter) const;
|
||||
|
||||
@@ -755,7 +755,7 @@ InboundLedger::filterNodes(
|
||||
*/
|
||||
// data must not have hash prefix
|
||||
bool
|
||||
InboundLedger::takeHeader(std::string const& data)
|
||||
InboundLedger::takeHeader(std::string_view data)
|
||||
{
|
||||
// Return value: true=normal, false=bad data
|
||||
JLOG(journal_.trace()) << "got header acquiring ledger " << hash_;
|
||||
@@ -903,7 +903,7 @@ InboundLedger::receiveNode(protocol::TMLedgerData& packet, SHAMapAddNode& san)
|
||||
Call with a lock
|
||||
*/
|
||||
bool
|
||||
InboundLedger::takeAsRootNode(std::string const& data, SHAMapAddNode& san)
|
||||
InboundLedger::takeAsRootNode(std::string_view data, SHAMapAddNode& san)
|
||||
{
|
||||
if (failed_ || mHaveState)
|
||||
{
|
||||
@@ -937,7 +937,7 @@ InboundLedger::takeAsRootNode(std::string const& data, SHAMapAddNode& san)
|
||||
Call with a lock
|
||||
*/
|
||||
bool
|
||||
InboundLedger::takeTxRootNode(std::string const& data, SHAMapAddNode& san)
|
||||
InboundLedger::takeTxRootNode(std::string_view data, SHAMapAddNode& san)
|
||||
{
|
||||
if (failed_ || mHaveTransactions)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ validateLedgerNode(protocol::TMLedgerNode const& ledger_node)
|
||||
}
|
||||
|
||||
std::optional<intr_ptr::SharedPtr<SHAMapTreeNode>>
|
||||
getTreeNode(std::string const& data)
|
||||
getTreeNode(std::string_view data)
|
||||
{
|
||||
auto const slice = makeSlice(data);
|
||||
try
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <xrpl/shamap/SHAMapTreeNode.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace protocol {
|
||||
class TMLedgerNode;
|
||||
@@ -42,7 +42,7 @@ validateLedgerNode(protocol::TMLedgerNode const& ledger_node);
|
||||
* deserialization fails.
|
||||
*/
|
||||
[[nodiscard]] std::optional<intr_ptr::SharedPtr<SHAMapTreeNode>>
|
||||
getTreeNode(std::string const& data);
|
||||
getTreeNode(std::string_view data);
|
||||
|
||||
/**
|
||||
* @brief Extracts or reconstructs the SHAMapNodeID from a ledger node proto message.
|
||||
|
||||
Reference in New Issue
Block a user