Skip to content

Commit 01b2988

Browse files
perf(container): improve dynamic construction of static depencies
1 parent f83d33c commit 01b2988

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/container.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ export interface ContainerConfiguration {
7474
function invokeWithDynamicDependencies(container, fn, staticDependencies, dynamicDependencies) {
7575
let i = staticDependencies.length;
7676
let args = new Array(i);
77+
let lookup;
7778

7879
while (i--) {
79-
if (staticDependencies[i] === null || staticDependencies[i] === undefined) {
80+
lookup = staticDependencies[i];
81+
82+
if (lookup === null || lookup === undefined) {
8083
throw new Error('Constructor Parameter with index ' + i + ' cannot be null or undefined. Are you trying to inject/register something that doesn\'t exist with DI?');
81-
} else
82-
args[i] = container.get(staticDependencies[i]);
84+
} else {
85+
args[i] = container.get(lookup);
86+
}
8387
}
8488

8589
if (dynamicDependencies !== undefined) {

0 commit comments

Comments
 (0)