Skip to content

Commit

Permalink
src: fix performance-faster-string-find in node_report.cc
Browse files Browse the repository at this point in the history
PR-URL: #27262
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
  • Loading branch information
gengjiawen authored and ZYSzys committed Apr 19, 2019
1 parent 02885da commit 7581910
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -349,15 +349,15 @@ 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) {
return !std::iswspace(ch);
}));
writer->json_element(l);
ss = ss.substr(line + 1);
line = ss.find("\n");
line = ss.find('\n');
}
}
writer->json_arrayend();
Expand Down

0 comments on commit 7581910

Please sign in to comment.