Skip to content

Commit 46ed6f0

Browse files
authored
improve performance of getIconSize() (#10125)
* load icons once on module load
1 parent edae807 commit 46ed6f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/svg-helpers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import SVGPathCommander from 'svg-path-commander'
22
import loadSimpleIcons from './load-simple-icons.js'
33

4+
const simpleIcons = loadSimpleIcons()
5+
46
function svg2base64(svg) {
57
return `data:image/svg+xml;base64,${Buffer.from(svg.trim()).toString(
68
'base64',
79
)}`
810
}
911

1012
function getIconSize(iconKey) {
11-
const simpleIcons = loadSimpleIcons()
12-
1313
if (!(iconKey in simpleIcons)) {
1414
return undefined
1515
}

0 commit comments

Comments
 (0)