Skip to content

Commit

Permalink
src: apply clang-tidy performance-faster-string-find
Browse files Browse the repository at this point in the history
PR-URL: #26812
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
gengjiawen authored and targos committed Mar 27, 2019
1 parent 963d7d1 commit de50346
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/inspector_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,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;
Expand Down
2 changes: 1 addition & 1 deletion src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit de50346

Please sign in to comment.