From 46ed6f02db0c4fe1546922221bf1a9340eab0eaf Mon Sep 17 00:00:00 2001 From: chris48s Date: Fri, 26 Apr 2024 19:46:57 +0100 Subject: [PATCH] improve performance of getIconSize() (#10125) * load icons once on module load --- lib/svg-helpers.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svg-helpers.js b/lib/svg-helpers.js index f564ab3555049..1ccb288992b40 100644 --- a/lib/svg-helpers.js +++ b/lib/svg-helpers.js @@ -1,6 +1,8 @@ import SVGPathCommander from 'svg-path-commander' import loadSimpleIcons from './load-simple-icons.js' +const simpleIcons = loadSimpleIcons() + function svg2base64(svg) { return `data:image/svg+xml;base64,${Buffer.from(svg.trim()).toString( 'base64', @@ -8,8 +10,6 @@ function svg2base64(svg) { } function getIconSize(iconKey) { - const simpleIcons = loadSimpleIcons() - if (!(iconKey in simpleIcons)) { return undefined }