Speed up constructor spreads.
Replace slow .bind with manual .create+.apply. Gives up to 19x speed up depending on browser. http://jsperf.com/apply-constructor
This commit is contained in:
parent
d50d4972a7
commit
f1f5f8bb27
@ -1,5 +1,5 @@
|
||||
(function (Constructor, args) {
|
||||
var bindArgs = [null].concat(args);
|
||||
var Factory = Constructor.bind.apply(Constructor, bindArgs);
|
||||
return new Factory;
|
||||
var instance = Object.create(Constructor);
|
||||
Constructor.apply(instance, args);
|
||||
return instance;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user