From de5034643fca2bcc1303fe80e5c00e7b1270d3de Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Wed, 20 Mar 2019 20:55:22 +0800 Subject: [PATCH] src: apply clang-tidy performance-faster-string-find PR-URL: https://github.com/nodejs/node/pull/26812 Reviewed-By: Richard Lau Reviewed-By: Refael Ackermann Reviewed-By: James M Snell --- src/inspector_socket.cc | 4 ++-- src/node_report.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc index a95f768e16553a..2e9a0a1fc2c07a 100644 --- a/src/inspector_socket.cc +++ b/src/inspector_socket.cc @@ -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; diff --git a/src/node_report.cc b/src/node_report.cc index 00d6a2454c6533..f9cf9211434bfc 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -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);