aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-03-26 20:17:46 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-03-26 20:17:46 +0100
commit516b75f66ec3ba7495fc028c750937bd66cc9bba (patch)
tree241cb9a4167cadecf39ecb7b939d8286c942a304
parent483fb8d2165bacafe9c12a829afca248feeeb42f (diff)
downloadbitcoin-516b75f66ec3ba7495fc028c750937bd66cc9bba.tar.xz
clang-tidy: Add `performance-faster-string-find` check
https://clang.llvm.org/extra/clang-tidy/checks/performance/faster-string-find.html
-rw-r--r--src/.clang-tidy1
-rw-r--r--src/rpc/util.cpp4
-rw-r--r--src/util/bip32.cpp2
-rw-r--r--src/zmq/zmqpublishnotifier.cpp2
4 files changed, 5 insertions, 4 deletions
diff --git a/src/.clang-tidy b/src/.clang-tidy
index b2c1b49588..dc26a640b6 100644
--- a/src/.clang-tidy
+++ b/src/.clang-tidy
@@ -5,6 +5,7 @@ bugprone-use-after-move,
misc-unused-using-decls,
modernize-use-default-member-init,
modernize-use-nullptr,
+performance-faster-string-find,
performance-for-range-copy,
performance-move-const-arg,
performance-no-automatic-move,
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index a1020c3b2b..ae1440c70b 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -732,12 +732,12 @@ UniValue RPCArg::MatchesType(const UniValue& request) const
std::string RPCArg::GetFirstName() const
{
- return m_names.substr(0, m_names.find("|"));
+ return m_names.substr(0, m_names.find('|'));
}
std::string RPCArg::GetName() const
{
- CHECK_NONFATAL(std::string::npos == m_names.find("|"));
+ CHECK_NONFATAL(std::string::npos == m_names.find('|'));
return m_names;
}
diff --git a/src/util/bip32.cpp b/src/util/bip32.cpp
index c4b7120394..c0ad9257ce 100644
--- a/src/util/bip32.cpp
+++ b/src/util/bip32.cpp
@@ -25,7 +25,7 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa
}
// Finds whether it is hardened
uint32_t path = 0;
- size_t pos = item.find("'");
+ size_t pos = item.find('\'');
if (pos != std::string::npos) {
// The hardened tick can only be in the last index of the string
if (pos != item.size() - 1) {
diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp
index 6418455d19..55f3d4e934 100644
--- a/src/zmq/zmqpublishnotifier.cpp
+++ b/src/zmq/zmqpublishnotifier.cpp
@@ -96,7 +96,7 @@ static bool IsZMQAddressIPV6(const std::string &zmq_address)
{
const std::string tcp_prefix = "tcp://";
const size_t tcp_index = zmq_address.rfind(tcp_prefix);
- const size_t colon_index = zmq_address.rfind(":");
+ const size_t colon_index = zmq_address.rfind(':');
if (tcp_index == 0 && colon_index != std::string::npos) {
const std::string ip = zmq_address.substr(tcp_prefix.length(), colon_index - tcp_prefix.length());
CNetAddr addr;