Skip to content

Commit fc7b507

Browse files
committed
tidy: add clang-tidy modernize-use-starts-ends-with check
1 parent 2756797 commit fc7b507

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

src/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ modernize-use-emplace,
1414
modernize-use-equals-default,
1515
modernize-use-noexcept,
1616
modernize-use-nullptr,
17+
modernize-use-starts-ends-with,
1718
performance-*,
1819
-performance-avoid-endl,
1920
-performance-enum-size,

src/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static void http_request_cb(struct evhttp_request* req, void* arg)
315315
if (i->exactMatch)
316316
match = (strURI == i->prefix);
317317
else
318-
match = (strURI.substr(0, i->prefix.size()) == i->prefix);
318+
match = strURI.starts_with(i->prefix);
319319
if (match) {
320320
path = strURI.substr(i->prefix.size());
321321
break;

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13561356
if (!SplitHostPort(socket_addr, port_out, host_out)) {
13571357
#ifdef HAVE_SOCKADDR_UN
13581358
// Allow unix domain sockets for some options e.g. unix:/some/file/path
1359-
if (!unix || socket_addr.find(ADDR_PREFIX_UNIX) != 0) {
1359+
if (!unix || !socket_addr.starts_with(ADDR_PREFIX_UNIX)) {
13601360
return InitError(InvalidPortErrMsg(arg, socket_addr));
13611361
}
13621362
#else

src/netbase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ CService LookupNumeric(const std::string& name, uint16_t portDefault, DNSLookupF
230230
bool IsUnixSocketPath(const std::string& name)
231231
{
232232
#ifdef HAVE_SOCKADDR_UN
233-
if (name.find(ADDR_PREFIX_UNIX) != 0) return false;
233+
if (!name.starts_with(ADDR_PREFIX_UNIX)) return false;
234234

235235
// Split off "unix:" prefix
236236
std::string str{name.substr(ADDR_PREFIX_UNIX.length())};

0 commit comments

Comments
 (0)