perf(ui): tighten Shiki highlight caches and parallelize fences
Use content fingerprints instead of full source as cache keys, record entry sizes once (no TextEncoder/JSON.stringify on get/evict), and highlight multiple markdown fences concurrently. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com>
This commit is contained in:
co-authored by
Serhii Dziupin
parent
6ab12fdb61
commit
c3c47e8956
@@ -1117,18 +1117,14 @@ const SimpleMarkdownRendererImpl: React.FC<{
|
||||
|
||||
const syntaxVars = React.useMemo(() => getMarkdownSyntaxVars(currentTheme), [currentTheme]);
|
||||
const ctx = useDecorateContext(currentTheme, false, undefined, mermaidControls);
|
||||
// Content-addressed render cache (see markdownCore) ignores this string for
|
||||
// lookup; keep a stable per-content key so effect deps stay aligned with text.
|
||||
const cacheKey = React.useMemo(
|
||||
() => `simple:${variant}:${renderedContent.length}:${renderedContent.slice(0, 64)}`,
|
||||
[variant, renderedContent],
|
||||
);
|
||||
|
||||
useMorphdomMarkdown({
|
||||
containerRef,
|
||||
text: renderedContent,
|
||||
streaming: false,
|
||||
cacheKey,
|
||||
// Identity is unused for cache lookup (content-addressed in markdownCore);
|
||||
// keep a stable per-variant key for effect deps alongside `text`.
|
||||
cacheKey: `simple:${variant}`,
|
||||
syntaxVars,
|
||||
ctx,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user