Skip to content

Commit

Permalink
v8: fix RegExp nits in v8_prof_polyfill.js
Browse files Browse the repository at this point in the history
* Do not repeat RegExp creation in cycle.
* Use sufficient string instead of RegExp in split().

PR-URL: #13709
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed Aug 16, 2017
1 parent 5a93c16 commit ae3e7be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/v8_prof_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ function versionCheck() {
function macCppfiltNm(out) {
// Re-grouped copy-paste from `tickprocessor.js`
const FUNC_RE = /^([0-9a-fA-F]{8,16} [iItT] )(.*)$/gm;
const CLEAN_RE = /^[0-9a-fA-F]{8,16} [iItT] /;
let entries = out.match(FUNC_RE);
if (entries === null)
return out;

entries = entries.map((entry) => {
return entry.replace(/^[0-9a-fA-F]{8,16} [iItT] /, '')
return entry.replace(CLEAN_RE, '')
});

let filtered;
Expand All @@ -123,7 +124,7 @@ function macCppfiltNm(out) {
}

let i = 0;
filtered = filtered.split(/\n/g);
filtered = filtered.split('\n');
return out.replace(FUNC_RE, (all, prefix, postfix) => {
return prefix + (filtered[i++] || postfix);
});
Expand Down

0 comments on commit ae3e7be

Please sign in to comment.