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/gstore.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gstore.c') diff --git a/src/gstore.c b/src/gstore.c index c5109c6..d2bc57f 100644 --- a/src/gstore.c +++ b/src/gstore.c @@ -355,9 +355,8 @@ uint32_t term_gstore_intern(struct gstore *g, const uint32_t *cps, int n) if (n > 2) { size_t extra = (size_t)(n - 2); if (g->arena_len + extra > g->arena_cap) { - size_t new_cap = g->arena_cap ? g->arena_cap * 2 : 512; - while (new_cap < g->arena_len + extra) - new_cap *= 2; + size_t new_cap = term_grow_cap(g->arena_cap ? g->arena_cap * 2 : 512, + g->arena_len + extra); uint32_t *next = realloc(g->arena, new_cap * sizeof(*next)); if (!next) { e->allocated = false; -- cgit v1.2.3