Skip to content

Commit 022f932

Browse files
fehrenbachpaf31
authored andcommitted
Reuse the array returned by match (#89)
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.
1 parent 6558a55 commit 022f932

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Data/String/Regex.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ exports._match = function (just) {
4949
if (m == null) {
5050
return nothing;
5151
} else {
52-
var list = [];
5352
for (var i = 0; i < m.length; i++) {
54-
list.push(m[i] == null ? nothing : just(m[i]));
53+
m[i] = m[i] == null ? nothing : just(m[i]);
5554
}
56-
return just(list);
55+
return just(m);
5756
}
5857
};
5958
};

0 commit comments

Comments
 (0)