From f6bd00315a5192b118675d810771ab0ba712f0c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Mond=C3=A9jar?= Date: Mon, 14 Dec 2020 16:37:15 +0100 Subject: [PATCH] Optimize package getter (#4356) Remove redundant truthy check for properties of icons in index.js We test if all icon scan be retrieved anyway, if any icon is missing these properties we would find out during testing. --- scripts/templates/index.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/templates/index.js b/scripts/templates/index.js index 7a4d025a5..18823bb4d 100644 --- a/scripts/templates/index.js +++ b/scripts/templates/index.js @@ -5,14 +5,12 @@ Object.defineProperty(icons, "get", { value: function(targetName) { if (icons[targetName]) { return icons[targetName]; - } else { - var normalizedName = targetName.toLowerCase(); - for (var iconName in icons) { - var icon = icons[iconName]; - if ((icon.title && icon.title.toLowerCase() === normalizedName) - || (icon.slug && icon.slug === normalizedName)) { - return icon; - } + } + var normalizedName = targetName.toLowerCase(); + for (var iconName in icons) { + var icon = icons[iconName]; + if (icon.title.toLowerCase() === normalizedName || icon.slug === normalizedName) { + return icon; } } }