Browse Source

v8: fix RegExp nits in v8_prof_polyfill.js

* Do not repeat RegExp creation in cycle.
* Use sufficient string instead of RegExp in split().

PR-URL: https://github.com/nodejs/node/pull/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>
v6
Vse Mozhet Byt 8 years ago
parent
commit
6b9500bfc2
  1. 5
      lib/internal/v8_prof_polyfill.js

5
lib/internal/v8_prof_polyfill.js

@ -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;
@ -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);
});

Loading…
Cancel
Save