mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Fix _.createCallback perf regression.
Former-commit-id: a66821a2c4aa3bae626e19ef638a27689b96dc24
This commit is contained in:
18
lodash.js
18
lodash.js
@@ -4848,20 +4848,20 @@
|
||||
return result;
|
||||
};
|
||||
}
|
||||
var bindData = func.__bindData__;
|
||||
// exit early if there is no `thisArg`
|
||||
if (typeof thisArg == 'undefined') {
|
||||
return func;
|
||||
}
|
||||
var bindData = !func.name || func.__bindData__;
|
||||
if (typeof bindData == 'undefined') {
|
||||
// checks if `func` references the `this` keyword and stores the result
|
||||
bindData = !reThis || reThis.test(fnToString.call(func));
|
||||
setBindData(func, bindData);
|
||||
}
|
||||
if (typeof thisArg == 'undefined' || !bindData) {
|
||||
// exit early if there are no `this` references or `func` is bound
|
||||
if (bindData !== true && !(bindData && bindData[4])) {
|
||||
return func;
|
||||
}
|
||||
else if (bindData !== true) {
|
||||
// exit early if already bound or leverage bind optimizations if
|
||||
// created by `_.partial` or `_.partialRight`
|
||||
return bindData[4] ? bind(func, thisArg) : func;
|
||||
}
|
||||
switch (argCount) {
|
||||
case 1: return function(value) {
|
||||
return func.call(thisArg, value);
|
||||
@@ -4876,9 +4876,7 @@
|
||||
return func.call(thisArg, accumulator, value, index, collection);
|
||||
};
|
||||
}
|
||||
return function() {
|
||||
return func.apply(thisArg, arguments);
|
||||
};
|
||||
return bind(func, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user