Merge bitcoin/bitcoin#21996: p2p: pass strings to NetPermissions::TryParse functions by const ref

39393479c5 p2p: pass strings to NetPermissions::TryParse functions by const ref (Jon Atack)

Pull request description:

  instead of by value, as these are "in" params that are not cheap to copy.

  Reference: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#f16-for-in-parameters-pass-cheaply-copied-types-by-value-and-others-by-reference-to-const

ACKs for top commit:
  MarcoFalke:
    cr ACK 39393479c5

Tree-SHA512: 294fe0f2d900293b4447d4e1f0ccc60c1ed27b3bdbd0f5d71d3dbf71de86879638b1b813fadfb44c58b4acff4e7d75b7ed6a4f9cc5fcf627108224e6a21b524c
This commit is contained in:
MarcoFalke 2021-05-19 21:01:21 +02:00
commit ff438a1966
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 6 additions and 6 deletions

View file

@ -20,8 +20,8 @@ const std::vector<std::string> NET_PERMISSIONS_DOC{
namespace {
// The parse the following format "perm1,perm2@xxxxxx"
bool TryParsePermissionFlags(const std::string str, NetPermissionFlags& output, size_t& readen, bilingual_str& error)
// Parse the following format: "perm1,perm2@xxxxxx"
bool TryParsePermissionFlags(const std::string& str, NetPermissionFlags& output, size_t& readen, bilingual_str& error)
{
NetPermissionFlags flags = NetPermissionFlags::None;
const auto atSeparator = str.find('@');
@ -81,7 +81,7 @@ std::vector<std::string> NetPermissions::ToStrings(NetPermissionFlags flags)
return strings;
}
bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermissions& output, bilingual_str& error)
bool NetWhitebindPermissions::TryParse(const std::string& str, NetWhitebindPermissions& output, bilingual_str& error)
{
NetPermissionFlags flags;
size_t offset;
@ -104,7 +104,7 @@ bool NetWhitebindPermissions::TryParse(const std::string str, NetWhitebindPermis
return true;
}
bool NetWhitelistPermissions::TryParse(const std::string str, NetWhitelistPermissions& output, bilingual_str& error)
bool NetWhitelistPermissions::TryParse(const std::string& str, NetWhitelistPermissions& output, bilingual_str& error)
{
NetPermissionFlags flags;
size_t offset;

View file

@ -74,14 +74,14 @@ public:
class NetWhitebindPermissions : public NetPermissions
{
public:
static bool TryParse(const std::string str, NetWhitebindPermissions& output, bilingual_str& error);
static bool TryParse(const std::string& str, NetWhitebindPermissions& output, bilingual_str& error);
CService m_service;
};
class NetWhitelistPermissions : public NetPermissions
{
public:
static bool TryParse(const std::string str, NetWhitelistPermissions& output, bilingual_str& error);
static bool TryParse(const std::string& str, NetWhitelistPermissions& output, bilingual_str& error);
CSubNet m_subnet;
};