mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[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:
parent
3e28ad62f4
commit
fc949de24f
1 changed files with 10 additions and 1 deletions
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue