src: apply clang-tidy performance-faster-string-find
PR-URL: https://github.com/nodejs/node/pull/26812 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
7d201c4e70
commit
86e0296631
@ -156,10 +156,10 @@ static void generate_accept_string(const std::string& client_key,
|
||||
}
|
||||
|
||||
static std::string TrimPort(const std::string& host) {
|
||||
size_t last_colon_pos = host.rfind(":");
|
||||
size_t last_colon_pos = host.rfind(':');
|
||||
if (last_colon_pos == std::string::npos)
|
||||
return host;
|
||||
size_t bracket = host.rfind("]");
|
||||
size_t bracket = host.rfind(']');
|
||||
if (bracket == std::string::npos || last_colon_pos > bracket)
|
||||
return host.substr(0, last_colon_pos);
|
||||
return host;
|
||||
|
@ -507,7 +507,7 @@ static void PrintSystemInformation(JSONWriter* writer) {
|
||||
WideCharToMultiByte(
|
||||
CP_UTF8, 0, lpszVariable, -1, str, size, nullptr, nullptr);
|
||||
std::string env(str);
|
||||
int sep = env.rfind("=");
|
||||
int sep = env.rfind('=');
|
||||
std::string key = env.substr(0, sep);
|
||||
std::string value = env.substr(sep + 1);
|
||||
writer->json_keyvalue(key, value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user