From b435df8640a26566952ee7ae1f840a9fff325fbe Mon Sep 17 00:00:00 2001 From: Giacomo Cavalieri Date: Wed, 15 Jul 2026 16:21:19 +0200 Subject: [PATCH] make javascript code generation faster by skipping grapheme counting in docs --- compiler-core/src/javascript.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler-core/src/javascript.rs b/compiler-core/src/javascript.rs index 291d19e35..269293755 100644 --- a/compiler-core/src/javascript.rs +++ b/compiler-core/src/javascript.rs @@ -1303,7 +1303,13 @@ fn jsdoc_comment<'a, 'doc>( documentation .trim_end() .split('\n') - .map(|line| eco_format!(" *{}", line.replace("*/", "*\\/")).to_doc(arena)), + // Each comment line is turned into a zero width string. + // We actually don't need to know how long a comment string is + // because comments will never be split anyway. + // So this saves us a lot of useless grapheme counting that would + // otherwise have to happen if we just turned the string into a + // regular document. + .map(|line| arena.zero_width_string(eco_format!(" *{}", line.replace("*/", "*\\/")))), LINE_DOCUMENT, ); -- 2.51.2