From 3b0d306c0fa20af4803fdad2313f250d4e388d35 Mon Sep 17 00:00:00 2001 From: James Smith Date: Wed, 6 Jun 2018 21:24:58 +0100 Subject: [PATCH] Optimization for Eq Array Running Eq on large nested data structures can be expensive (think rose trees with 10^5 items), so checking for reference equality before traversing the array can result in some significant gains. --- src/Data/Eq.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Eq.js b/src/Data/Eq.js index 1c62da2d..b8356847 100644 --- a/src/Data/Eq.js +++ b/src/Data/Eq.js @@ -9,6 +9,7 @@ exports.refEq = function (r1) { exports.eqArrayImpl = function (f) { return function (xs) { return function (ys) { + if (xs === ys) return true; if (xs.length !== ys.length) return false; for (var i = 0; i < xs.length; i++) { if (!f(xs[i])(ys[i])) return false;