Skip to content

Commit 293d0b5

Browse files
committed
Further performance boost for traverseArray
Using a 'class' as @garyb suggested has given a performance boost of around 2.4x on Node.js
1 parent a1ef3d7 commit 293d0b5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Data/Traversable.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33

44
// module Data.Traversable
55

6+
// jshint maxparams: 3
7+
68
exports.traverseArrayImpl = function () {
79
function Cont (fn) {
810
this.fn = fn;
911
}
1012

1113
var emptyList = {};
1214

15+
var ConsCell = function (head, tail) {
16+
this.head = head;
17+
this.tail = tail;
18+
};
19+
1320
function consList (x) {
1421
return function (xs) {
15-
return { head: x, tail: xs };
22+
return new ConsCell(x, xs);
1623
};
1724
}
1825

@@ -29,12 +36,10 @@ exports.traverseArrayImpl = function () {
2936
return function (map) {
3037
return function (pure) {
3138
return function (f) {
32-
/* jshint maxparams: 2 */
3339
var buildFrom = function (x, ys) {
3440
return apply(map(consList)(f(x)))(ys);
3541
};
3642

37-
/* jshint maxparams: 3 */
3843
var go = function (acc, currentLen, xs) {
3944
if (currentLen === 0) {
4045
return acc;

0 commit comments

Comments
 (0)