aboutsummaryrefslogtreecommitdiffstats
path: root/src/Injector.js
diff options
context:
space:
mode:
authorIgor Minar2011-12-16 12:45:20 -0800
committerMisko Hevery2012-01-25 11:46:35 -0800
commit1e96d0af8cd235db94c937acd849cd6061df3e87 (patch)
treecd364fd8e36dfe4e50b44ee49f7a1fe0dfcaefb7 /src/Injector.js
parent97dae0d0a0226ee527771578bfad1342d51bf4dd (diff)
downloadangular.js-1e96d0af8cd235db94c937acd849cd6061df3e87.tar.bz2
fix(injector): small perf improvement & code cleanup
Diffstat (limited to 'src/Injector.js')
-rw-r--r--src/Injector.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/Injector.js b/src/Injector.js
index 849ef3b9..38cf652d 100644
--- a/src/Injector.js
+++ b/src/Injector.js
@@ -384,25 +384,29 @@ function createInjector(modulesToLoad) {
function invoke(fn, self, locals){
var args = [],
- $injectAnnotation,
- $injectAnnotationIndex,
+ $inject,
+ length,
key;
if (typeof fn == 'function') {
- $injectAnnotation = inferInjectionArgs(fn);
- $injectAnnotationIndex = $injectAnnotation.length;
+ $inject = inferInjectionArgs(fn);
+ length = $inject.length;
} else {
if (isArray(fn)) {
- $injectAnnotation = fn;
- $injectAnnotationIndex = $injectAnnotation.length;
- fn = $injectAnnotation[--$injectAnnotationIndex];
+ $inject = fn;
+ length = $inject.length - 1;
+ fn = $inject[length];
}
assertArgFn(fn, 'fn');
}
- while($injectAnnotationIndex--) {
- key = $injectAnnotation[$injectAnnotationIndex];
- args.unshift(locals && locals.hasOwnProperty(key) ? locals[key] : getService(key));
+ for(var i = 0; i < length; i++) {
+ key = $inject[i];
+ args.push(
+ locals && locals.hasOwnProperty(key)
+ ? locals[key]
+ : getService(key, path)
+ );
}
// Performance optimization: http://jsperf.com/apply-vs-call-vs-invoke