Only use SetCache in baseIntersection only when arrays[0] is large.

This commit is contained in:
John-David Dalton
2016-02-27 20:44:19 -08:00
parent 98bdd67cf2
commit dfd865dadc

View File

@@ -2766,6 +2766,7 @@
*/ */
function baseIntersection(arrays, iteratee, comparator) { function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes, var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length, othLength = arrays.length,
othIndex = othLength, othIndex = othLength,
caches = Array(othLength), caches = Array(othLength),
@@ -2777,14 +2778,12 @@
if (othIndex && iteratee) { if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee)); array = arrayMap(array, baseUnary(iteratee));
} }
var length = array.length; maxLength = nativeMin(array.length, maxLength);
maxLength = length < maxLength ? length : maxLength; caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
caches[othIndex] = !comparator && (iteratee || length >= 120)
? new SetCache(othIndex && array) ? new SetCache(othIndex && array)
: undefined; : undefined;
} }
array = arrays[0]; array = arrays[0];
length = array.length;
var index = -1, var index = -1,
seen = caches[0]; seen = caches[0];