diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 13:36:27 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 13:36:27 +0300 |
| commit | 4741f7a6dfa144ce65cf3bbdd4a1bc6bee6df2e5 (patch) | |
| tree | 97932e58eee98623b56a9d9181a3b4289b6ecfc1 /src/gstore.c | |
| parent | a0fefd3856a4f03be0abbc51f7a9a0416db69eb5 (diff) | |
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
Diffstat (limited to 'src/gstore.c')
| -rw-r--r-- | src/gstore.c | 5 |
1 files changed, 2 insertions, 3 deletions
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; |
