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 <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
vsemozhetbyt authored and addaleax committed Jun 21, 2017
1 parent b2a5399 commit c68e472
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 c68e472

Please sign in to comment.