From 670440f55200671337cdfc69b64d7f06b3d226ff Mon Sep 17 00:00:00 2001 From: Stefan Fehrenbach Date: Fri, 17 Nov 2017 22:20:24 +0000 Subject: [PATCH] Reuse the array returned by match Instead of basically making a copy and letting the original go out of scope immediately after. This makes a surprisingly large performance difference in Chrome, not so much in Firefox. --- src/Data/String/Regex.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Data/String/Regex.js b/src/Data/String/Regex.js index 1d7e407..2e3ac3b 100644 --- a/src/Data/String/Regex.js +++ b/src/Data/String/Regex.js @@ -49,11 +49,10 @@ exports._match = function (just) { if (m == null) { return nothing; } else { - var list = []; for (var i = 0; i < m.length; i++) { - list.push(m[i] == null ? nothing : just(m[i])); + m[i] = m[i] == null ? nothing : just(m[i]); } - return just(list); + return just(m); } }; };