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 <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
  • 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.