From 60713f0e5f1ee963bbc54b50235e0526c2d2cf53 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Sat, 22 Nov 2014 14:20:55 +0200 Subject: [PATCH] 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 --- lib/6to5/templates/apply-constructor.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/6to5/templates/apply-constructor.js b/lib/6to5/templates/apply-constructor.js index b02f831251..0c61411455 100644 --- a/lib/6to5/templates/apply-constructor.js +++ b/lib/6to5/templates/apply-constructor.js @@ -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.prototype); + Constructor.apply(instance, args); + return instance; });