Skip to content

Commit e1aaaa7

Browse files
committed
fix: small segmenter optimisation
1 parent 652014c commit e1aaaa7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/components/BlueskyComment.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ function getHostname(uri: string): string {
3939
}
4040
}
4141
42+
let segmenter: Intl.Segmenter | null = null
4243
function firstChar(str: string): string {
43-
const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' })
44+
segmenter ??= new Intl.Segmenter(undefined, { granularity: 'grapheme' })
4445
return Array.from(segmenter.segment(str))[0]?.segment ?? ''
4546
}
4647
</script>

0 commit comments

Comments
 (0)