From d5bf1379b5946aa2e69bd29d54cc37382a211f30 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Fri, 16 Jun 2017 02:17:10 +0300 Subject: [PATCH] v8: fix RegExp nits in v8_prof_polyfill.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/v8_prof_polyfill.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/v8_prof_polyfill.js b/lib/internal/v8_prof_polyfill.js index 34cd10337f12a1..e77f1f76bcb9ee 100644 --- a/lib/internal/v8_prof_polyfill.js +++ b/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); });