optimization: cache some calculation (on every file listed from disk)

Massimo Melina committed Sep 15, 2025 at 19:29 UTC 5abf388bca31156459ba22af620d2452e2a69489
1 file changed +3 -2
src/comments.ts
+3 -2
@@ -8,7 +8,8 @@ import iconv from 'iconv-lite'
8 import { unlink } from 'node:fs/promises'
9
10 export const DESCRIPT_ION = 'descript.ion'
11 -const commentsStorage = defineConfig<'' | 'attr' | 'attr+ion'>(CFG.comments_storage, '')
11 +const commentsStorage = defineConfig<'' | 'attr' | 'attr+ion'>(CFG.comments_storage, '',
12 + v => ['', 'attr+ion'].includes(v)) // compiled tell us if we are using descript.ion
13 defineConfig('descript_ion', true, (v, more) => { // legacy: convert previous setting
14 if (!v && more.version?.olderThan('0.57.0-alpha1'))
15 commentsStorage.set('attr')
@@ -20,7 +21,7 @@ function readFromDescriptIon(path: string) {
21 }
22
23 export function usingDescriptIon() {
23 - return ['', 'attr+ion'].includes(commentsStorage.get())
24 + return commentsStorage.compiled()
25 }
26
27 const COMMENT_ATTR = 'comment'