Skip to content

Commit

Permalink
Reuse the array returned by match (#89)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fehrenbach authored and paf31 committed Nov 19, 2017
1 parent 6558a55 commit 022f932
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Data/String/Regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
};
Expand Down

0 comments on commit 022f932

Please sign in to comment.