Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 44b6b72

Browse files
committed
fix($injector): don't parse fns with no args
When annotating a fn, it is wasteful to try to parse a fn that has no arguments as such fn has no injectable dependencies
1 parent 35d4993 commit 44b6b72

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/auto/injector.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,15 @@ function annotate(fn) {
5252
if (typeof fn == 'function') {
5353
if (!($inject = fn.$inject)) {
5454
$inject = [];
55-
fnText = fn.toString().replace(STRIP_COMMENTS, '');
56-
argDecl = fnText.match(FN_ARGS);
57-
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
58-
arg.replace(FN_ARG, function(all, underscore, name){
59-
$inject.push(name);
55+
if (fn.length) {
56+
fnText = fn.toString().replace(STRIP_COMMENTS, '');
57+
argDecl = fnText.match(FN_ARGS);
58+
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg){
59+
arg.replace(FN_ARG, function(all, underscore, name){
60+
$inject.push(name);
61+
});
6062
});
61-
});
63+
}
6264
fn.$inject = $inject;
6365
}
6466
} else if (isArray(fn)) {

0 commit comments

Comments
 (0)