From 20bfd29a5c6250a6e095bd776a6959001e97b59d Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Mon, 18 May 2020 23:09:09 +0300 Subject: [PATCH] refactor: set array lengths before loops --- .../packages/core/src/lib/utils/localization-utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts index 530adc0621..2a14b8d014 100644 --- a/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts +++ b/npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts @@ -22,10 +22,13 @@ export function localizeWithFallback( return function(localization: ApplicationConfiguration.Localization) { resourceNames = resourceNames.concat(localization.defaultResourceName).filter(Boolean); - for (let i = 0; i < resourceNames.length; i++) { + const resourceCount = resourceNames.length; + const keyCount = keys.length; + + for (let i = 0; i < resourceCount; i++) { const resourceName = resourceNames[i]; - for (let j = 0; j < keys.length; j++) { + for (let j = 0; j < keyCount; j++) { const localized = localize(resourceName, keys[j], null)(localization); if (localized) return localized; }