From f6589121da72b02c2aea12fedc098e597cae5e8e Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 12 Jun 2026 10:36:06 +0800 Subject: [PATCH] perf(markdown): eliminate duplicate clean_html call in generate_toc_html clean_html() triggers expensive ammonia sanitization with aho_corasick. Previously called twice for the same text (aria-label + display text). Now calls once and reuses the result. --- src/api/markdown.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/markdown.rs b/src/api/markdown.rs index b20c7c2..2ff53c3 100644 --- a/src/api/markdown.rs +++ b/src/api/markdown.rs @@ -228,11 +228,12 @@ fn generate_toc_html(headings: &[(u8, String, String)]) -> String { } } + let clean_text = clean_html(text); html.push_str(&format!( "
  • {}", id, - clean_html(text), - clean_html(text) + clean_text, + clean_text )); }