summaryrefslogtreecommitdiff
path: root/conf/conf.h
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2023-04-27 17:09:00 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2023-04-27 17:09:00 +0200
commit9b471e72d75c154f3b8c4fa134c7c9f1a55fe27f (patch)
tree9b48f388f4d3f87d243d8a9df1adfcddf75a7a2e /conf/conf.h
parentca0f239c72486cebfe171e335e3b8a86f5999714 (diff)
Conf: Fix symbol lookup
The symbol table used just symbol name as a key, and used a trick with active flag to find symbols in active scopes with one hash table lookup. The disadvantage is that it can degenerate to O(n) for negative queries in situations where are many symbols with the same name in different scopes. Thanks to Yanko Kaneti for the bugreport.
Diffstat (limited to 'conf/conf.h')
-rw-r--r--conf/conf.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/conf/conf.h b/conf/conf.h
index b409750e..cb47e7d0 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -187,7 +187,9 @@ int cf_lex(void);
void cf_lex_init(int is_cli, struct config *c);
void cf_lex_unwind(void);
-struct symbol *cf_find_symbol(const struct config *cfg, const byte *c);
+struct symbol *cf_find_local_symbol(const struct config *cfg, const struct sym_scope *scope, const byte *c);
+static inline struct symbol *cf_find_symbol(const struct config *cfg, const byte *c)
+{ return cf_find_local_symbol(cfg, cfg->root_scope, c); }
struct symbol *cf_get_symbol(const byte *c);
struct symbol *cf_default_name(char *template, int *counter);