mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Move switch optimization to negate.
This commit is contained in:
12
lodash.js
12
lodash.js
@@ -437,8 +437,7 @@
|
|||||||
* @returns {*} Returns the result of `func`.
|
* @returns {*} Returns the result of `func`.
|
||||||
*/
|
*/
|
||||||
function apply(func, thisArg, args) {
|
function apply(func, thisArg, args) {
|
||||||
var length = args.length;
|
switch (args.length) {
|
||||||
switch (length) {
|
|
||||||
case 0: return func.call(thisArg);
|
case 0: return func.call(thisArg);
|
||||||
case 1: return func.call(thisArg, args[0]);
|
case 1: return func.call(thisArg, args[0]);
|
||||||
case 2: return func.call(thisArg, args[0], args[1]);
|
case 2: return func.call(thisArg, args[0], args[1]);
|
||||||
@@ -10105,7 +10104,14 @@
|
|||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return function() {
|
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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user