From 49db349ffdd888f5e3c91abf9b7519d8631e6e9a Mon Sep 17 00:00:00 2001 From: Benjamin Carlsson Date: Sun, 16 Aug 2026 01:22:00 +0000 Subject: [PATCH] Avoid allocating per character when decorating hyperlinks (#38823) Encode each character into a stack buffer before appending it to the decorated span, avoiding a temporary `String` allocation for every character. GitOrigin-RevId: 72ec1ad5363391dffee089f04073d827d8c459bf --- codex-rs/tui/src/terminal_hyperlinks.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codex-rs/tui/src/terminal_hyperlinks.rs b/codex-rs/tui/src/terminal_hyperlinks.rs index e9580dc68c..b7ea9d75d9 100644 --- a/codex-rs/tui/src/terminal_hyperlinks.rs +++ b/codex-rs/tui/src/terminal_hyperlinks.rs @@ -461,7 +461,7 @@ pub(crate) fn decorate_spans(line: &HyperlinkLine) -> Vec> { } active_link_index = selected_link_index; } - push_styled_content(&mut out, &ch.to_string(), span.style); + push_styled_content(&mut out, ch.encode_utf8(&mut [0; 4]), span.style); column += width; } }