Optimize createBindWrapper, createPartialWrapper, and createHybridWrapper.

This commit is contained in:
jdalton
2015-03-08 01:00:04 -08:00
parent 6113da3e68
commit b5dce2f74b

View File

@@ -3213,7 +3213,8 @@
var Ctor = createCtorWrapper(func); var Ctor = createCtorWrapper(func);
function wrapper() { function wrapper() {
return (this instanceof wrapper ? Ctor : func).apply(thisArg, arguments); var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(thisArg, arguments);
} }
return wrapper; return wrapper;
} }
@@ -3416,7 +3417,8 @@
if (isAry && ary < args.length) { if (isAry && ary < args.length) {
args.length = ary; args.length = ary;
} }
return (this instanceof wrapper ? (Ctor || createCtorWrapper(func)) : func).apply(thisBinding, args); var fn = (this && this !== root && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func;
return fn.apply(thisBinding, args);
} }
return wrapper; return wrapper;
} }
@@ -3475,7 +3477,8 @@
while (argsLength--) { while (argsLength--) {
args[leftIndex++] = arguments[++argsIndex]; args[leftIndex++] = arguments[++argsIndex];
} }
return (this instanceof wrapper ? Ctor : func).apply(isBind ? thisArg : this, args); var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return fn.apply(isBind ? thisArg : this, args);
} }
return wrapper; return wrapper;
} }