From 05e4fd3488b89e670c36869f18defe26deac2efa Mon Sep 17 00:00:00 2001 From: Ben Wiklund Date: Thu, 12 Dec 2013 16:32:36 -0800 Subject: [PATCH] perf($injector): remove invoke optimization that doesn't work Closes #5388 --- src/auto/injector.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/auto/injector.js b/src/auto/injector.js index ee1d475cff0c..96ce83ea3bb2 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -769,24 +769,9 @@ function createInjector(modulesToLoad) { fn = fn[length]; } - - // Performance optimization: http://jsperf.com/apply-vs-call-vs-invoke - switch (self ? -1 : args.length) { - case 0: return fn(); - case 1: return fn(args[0]); - case 2: return fn(args[0], args[1]); - case 3: return fn(args[0], args[1], args[2]); - case 4: return fn(args[0], args[1], args[2], args[3]); - case 5: return fn(args[0], args[1], args[2], args[3], args[4]); - case 6: return fn(args[0], args[1], args[2], args[3], args[4], args[5]); - case 7: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); - case 8: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]); - case 9: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], - args[8]); - case 10: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], - args[8], args[9]); - default: return fn.apply(self, args); - } + // http://jsperf.com/angularjs-invoke-apply-vs-switch + // #5388 + return fn.apply(self, args); } function instantiate(Type, locals) {