From 498533d663a46233bfa3887f649a04ab4f71a9a2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 11 Jul 2026 19:53:19 -0700 Subject: [PATCH] terminal: avoid copying set lookup items Keep the resident RefCountedSet item behind a pointer while probing. The previous value copy materialized the complete generic item before checking its metadata and equality, which is especially costly for terminal styles. ReleaseFast timings are seven-run median user CPU times. | Workload | Before | After | Change | | --- | ---: | ---: | ---: | | 128 styles, live lookup | 0.80s | 0.74s | -7.5% | | 4,096 styles, live lookup | 0.92s | 0.87s | -5.4% | | Alternating SGR stream | 1.21s | 1.20s | -0.8% | --- src/terminal/ref_counted_set.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal/ref_counted_set.zig b/src/terminal/ref_counted_set.zig index cefd6a2d9..9c694dc02 100644 --- a/src/terminal/ref_counted_set.zig +++ b/src/terminal/ref_counted_set.zig @@ -560,7 +560,7 @@ pub fn RefCountedSet( return null; } - const item = items[id]; + const item = &items[id]; // An item with a shorter probe sequence length would never // end up in the middle of another sequence, since it would