Optimize _.intersection and _.intersectionBy for empty arrays.

This commit is contained in:
John-David Dalton
2015-10-05 10:53:41 -07:00
parent ed462747bf
commit 6d5c6b2de7

View File

@@ -5421,7 +5421,7 @@
*/ */
var intersection = restParam(function(arrays) { var intersection = restParam(function(arrays) {
var mapped = arrayMap(arrays, toArrayLikeObject); var mapped = arrayMap(arrays, toArrayLikeObject);
return mapped[0] === arrays[0] return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped) ? baseIntersection(mapped)
: []; : [];
}); });
@@ -5448,7 +5448,7 @@
*/ */
var intersectionBy = restParam(function(arrays) { var intersectionBy = restParam(function(arrays) {
var mapped = arrayMap(arrays, toArrayLikeObject); var mapped = arrayMap(arrays, toArrayLikeObject);
return mapped[0] === arrays[0] return (mapped.length && mapped[0] === arrays[0])
? baseIntersectionBy(mapped, getIteratee(last(arrays))) ? baseIntersectionBy(mapped, getIteratee(last(arrays)))
: []; : [];
}); });