From ccee818034d7dc67399276ac7986bd7c9733d355 Mon Sep 17 00:00:00 2001 From: NothingEverHappens Date: Mon, 11 Nov 2019 15:57:10 -0500 Subject: [PATCH] perf(core): Avoid unnecessary creating provider factory (#33742) In providerToRecord move creating the factory into a condition which actually needs it to avoid unnecessary creating it PR Close #33742 --- packages/core/src/di/r3_injector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/di/r3_injector.ts b/packages/core/src/di/r3_injector.ts index ab08322c81..f6af39c0c8 100644 --- a/packages/core/src/di/r3_injector.ts +++ b/packages/core/src/di/r3_injector.ts @@ -461,10 +461,10 @@ function getUndecoratedInjectableFactory(token: Function) { function providerToRecord( provider: SingleProvider, ngModuleType: InjectorType, providers: any[]): Record { - let factory: (() => any)|undefined = providerToFactory(provider, ngModuleType, providers); if (isValueProvider(provider)) { return makeRecord(undefined, provider.useValue); } else { + const factory: (() => any)|undefined = providerToFactory(provider, ngModuleType, providers); return makeRecord(factory, NOT_YET); } }