rpc: refactor: use string_view in Arg/MaybeArg

Modernizes interface by not forcing users to deal with raw pointers,
without adding copying overhead. Generalizes the logic of whether
we return by value or by optional/pointer.

In cases where functions take a `const std::string&` and it would
be too much work to update them, a string copy is made (which was
already happening anyway).
This commit is contained in:
stickies-v
2025-07-14 16:53:46 +01:00
parent 75353a0163
commit b3bf18f0ba
18 changed files with 51 additions and 46 deletions

View File

@@ -39,11 +39,12 @@
#include <algorithm>
#include <array>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <functional>
#include <optional>
#include <string_view>
#include <unordered_map>
TRACEPOINT_SEMAPHORE(net, closed_connection);
@@ -3562,11 +3563,11 @@ bool CConnman::AddNode(const AddedNodeParams& add)
return true;
}
bool CConnman::RemoveAddedNode(const std::string& strNode)
bool CConnman::RemoveAddedNode(std::string_view node)
{
LOCK(m_added_nodes_mutex);
for (auto it = m_added_node_params.begin(); it != m_added_node_params.end(); ++it) {
if (strNode == it->m_added_node) {
if (node == it->m_added_node) {
m_added_node_params.erase(it);
return true;
}