From 4741f7a6dfa144ce65cf3bbdd4a1bc6bee6df2e5 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 13:36:27 +0300 Subject: Optimize and simplify loops, table lookups, and branchless parsers - Replace sequential colon-counting loop with branchless CTZ bitmask in src/pen.h - Replace linear strchr with 256-bit ASCII punctuation bitmask in src/selection.c - Flatten 3D color cube loop and precompute constants in src/palette.c - Use static 256-byte LUT for hex decoding and bsearch for termcap in src/escape.c - Replace capacity doubling while loops with branchless CLZ pow2 helpers across core - Use direct memset/memcpy in src/snapshot.c - Optimize input digit/byte formatting, alt-prefix path, and make keyboard state optional in src/input.c --- src/palette.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/palette.h') diff --git a/src/palette.h b/src/palette.h index 5eef03e..f60e41e 100644 --- a/src/palette.h +++ b/src/palette.h @@ -28,7 +28,7 @@ void term_palette_reset_all(struct palette *p); static inline uint32_t palette_resolve(const struct palette *p, term_color c) { - return term_color_is_slot(c) ? p->colors[c & 0x1FFu] : c; + return term_color_is_slot(c) ? p->colors[c & TERM_COLOR_SLOT_INDEX] : c; } #endif -- cgit v1.2.3