From 758191033f8a50d54ebc21ff8fe640666ecd3236 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Tue, 16 Apr 2019 22:36:53 +0800 Subject: [PATCH] src: fix performance-faster-string-find in node_report.cc PR-URL: https://github.com/nodejs/node/pull/27262 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Yongsheng Zhang --- src/node_report.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_report.cc b/src/node_report.cc index 4d5d770b5c3b27..74391cd4c1bcc9 100644 --- a/src/node_report.cc +++ b/src/node_report.cc @@ -340,7 +340,7 @@ static void PrintJavaScriptStack(JSONWriter* writer, String::Utf8Value sv(isolate, stackstr); ss = std::string(*sv, sv.length()); } - int line = ss.find("\n"); + int line = ss.find('\n'); if (line == -1) { writer->json_keyvalue("message", ss); writer->json_objectend(); @@ -349,7 +349,7 @@ static void PrintJavaScriptStack(JSONWriter* writer, writer->json_keyvalue("message", l); writer->json_arraystart("stack"); ss = ss.substr(line + 1); - line = ss.find("\n"); + line = ss.find('\n'); while (line != -1) { l = ss.substr(0, line); l.erase(l.begin(), std::find_if(l.begin(), l.end(), [](int ch) { @@ -357,7 +357,7 @@ static void PrintJavaScriptStack(JSONWriter* writer, })); writer->json_element(l); ss = ss.substr(line + 1); - line = ss.find("\n"); + line = ss.find('\n'); } } writer->json_arrayend();