[cexpr] Fall back to a linear search if no hash

While hash tables are useful for large symbol tables, the bool "enum" is
too small to justify one and even bsearch is too expensive (also,
bsearch requires knowing the number of elements, which is a bit of a
hassle currently).
This commit is contained in:
Bill Currie 2023-06-26 11:51:12 +09:00
parent 3e28ad62f4
commit fc949de24f

View file

@ -326,7 +326,16 @@ parse_name (const char *name, exprctx_t *context)
} }
prev_tab = symtab; prev_tab = symtab;
if (symtab->tab) {
sym = Hash_Find (symtab->tab, name); sym = Hash_Find (symtab->tab, name);
} else {
for (exprsym_t *s = symtab->symbols; s->name; s++) {
if (!strcmp (s->name, name)) {
sym = s;
break;
}
}
}
} }
if (!sym) { if (!sym) {
sym = cmemalloc (context->memsuper, sizeof (exprsym_t)); sym = cmemalloc (context->memsuper, sizeof (exprsym_t));