From 6a41a79ded0158f8c5f5afe5f0c873d445a14a1d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 23 Jul 2016 21:47:47 -0700 Subject: [PATCH] Move switch optimization to `negate`. --- lodash.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index e6ec3e2ba..6ec57f239 100644 --- a/lodash.js +++ b/lodash.js @@ -437,8 +437,7 @@ * @returns {*} Returns the result of `func`. */ function apply(func, thisArg, args) { - var length = args.length; - switch (length) { + switch (args.length) { case 0: return func.call(thisArg); case 1: return func.call(thisArg, args[0]); case 2: return func.call(thisArg, args[0], args[1]); @@ -10105,7 +10104,14 @@ throw new TypeError(FUNC_ERROR_TEXT); } return function() { - return !predicate.apply(this, arguments); + var args = arguments; + switch (args.length) { + case 0: return !predicate.call(this); + case 1: return !predicate.call(this, args[0]); + case 2: return !predicate.call(this, args[0], args[1]); + case 3: return !predicate.call(this, args[0], args[1], args[2]); + } + return !predicate.apply(this, args); }; }