From 85b83d7a203641639b440b6a164b4075e00e91a6 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 21 Aug 2025 21:53:09 +0100 Subject: Small optimisation: don't initialise a symbol table immediately on init Why? This way, until we use symbols, the system doesn't generate the table and thus grow the memory usage by a couple kb. --- symtable.c | 4 ++++ sys.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/symtable.c b/symtable.c index c804344..15c6cd0 100644 --- a/symtable.c +++ b/symtable.c @@ -34,6 +34,10 @@ void sym_table_init(sym_table_t *table) char *sym_table_find(sym_table_t *table, sv_t sv) { + // Initialise the table if it's not done already + if (table->entries.capacity == 0) + sym_table_init(table); + // WIP: Deal with resizing this when table->count > table->size / 2 u64 index = djb2(sv) & (table->capacity - 1); diff --git a/sys.c b/sys.c index ac26a88..d01b493 100644 --- a/sys.c +++ b/sys.c @@ -20,8 +20,7 @@ void sys_init(sys_t *sys) { - sys->memory = NIL; - sym_table_init(&sys->symtable); + memset(sys, 0, sizeof(*sys)); } void sys_register(sys_t *sys, lisp_t *ptr) -- cgit v1.2.3-13-gbd6f