commit 02cecfe1ee79bd72dc1b388ec1d86095da6b2f4b
parent 325a68b5234a664320fcfb1d28031b87bc98e7de
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Sat, 13 Jun 2026 09:24:58 -0700
perf(lex): delete the dead per-lexer frontend Pool — lexer only read pool->c, which l->c already holds
Diffstat:
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/lang/cpp/lex/lex.c b/lang/cpp/lex/lex.c
@@ -95,7 +95,6 @@ static const u8 cclass[256] = {
struct Lexer {
Compiler* c;
- Pool* pool;
Heap* heap;
/* `src`/`len` are the post-phase-2 (line-splice-folded) logical bytes the
* scanner walks. When the input contains no `\<newline>` (the common case)
@@ -298,11 +297,6 @@ Lexer* lex_open_mem(Compiler* c, const char* name, const char* src,
if (!l) return NULL;
memset(l, 0, sizeof(*l));
l->c = c;
- l->pool = c_pool_new(c);
- if (!l->pool) {
- h->free(h, l, sizeof(*l));
- return NULL;
- }
l->heap = h;
lex_fold_splices(l, src ? src : "", src ? len : 0);
l->cur = l->src;
@@ -322,7 +316,6 @@ void lex_close(Lexer* l) {
if (l->owns_src) l->heap->free(l->heap, (char*)l->src, l->len);
if (l->splices)
l->heap->free(l->heap, l->splices, l->nsplices * sizeof(u32));
- c_pool_free(l->pool);
l->heap->free(l->heap, l, sizeof(*l));
}
@@ -350,7 +343,7 @@ u32 lex_file_id(const Lexer* l) { return l->file_id; }
/* Intern a token's spelling [a, b) straight from the folded buffer (it is
* already post-phase-2 logical text — splices were removed at open). */
static Sym lex_intern(Lexer* l, const char* a, const char* b) {
- return kit_sym_intern(l->pool->c,
+ return kit_sym_intern(l->c,
(KitSlice){.s = a, .len = (size_t)(b - a)});
}
@@ -607,7 +600,7 @@ static void finish_ident(Lexer* l, Tok* t, const char* tok_start) {
t->spelling = lex_intern(l, tok_start, l->cur);
t->v.ident = t->spelling;
if (l->dstate == 1) {
- KitSlice s = kit_sym_str(l->pool->c, t->spelling);
+ KitSlice s = kit_sym_str(l->c, t->spelling);
l->dstate = (s.s && matches_include_kw(s.s, s.len)) ? 2 : 0;
} else {
l->dstate = 0;
@@ -794,7 +787,7 @@ Tok lex_next(Lexer* l) {
break;
}
}
- t.spelling = kit_sym_intern(l->pool->c, (KitSlice){.s = text, .len = k});
+ t.spelling = kit_sym_intern(l->c, (KitSlice){.s = text, .len = k});
l->dstate = 0;
return t;
}