refactor: set array lengths before loops

pull/3996/head
Arman Ozak 5 years ago
parent 3ebbb709f6
commit 20bfd29a5c

@ -22,10 +22,13 @@ export function localizeWithFallback(
return function(localization: ApplicationConfiguration.Localization) { return function(localization: ApplicationConfiguration.Localization) {
resourceNames = resourceNames.concat(localization.defaultResourceName).filter(Boolean); 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]; 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); const localized = localize(resourceName, keys[j], null)(localization);
if (localized) return localized; if (localized) return localized;
} }

Loading…
Cancel
Save