From 1c40ff9faafed620aa0458b397bcbfbe19e0f663 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 17 Dec 2024 11:23:22 -0300 Subject: Scanner and parser use different tables for constants Moreover, each function being parsed has its own table. The code is cleaner when each table is used for one specific purpose: The scanner uses its table to anchor and unify strings, mapping strings to themselves; the parser uses it to reuse constants in the code, mapping constants to their indices in the constant table. A different table for each task avoids false collisions. --- ltable.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index 052e005e..eb5abf9f 100644 --- a/ltable.c +++ b/ltable.c @@ -962,7 +962,7 @@ lu_byte luaH_getint (Table *t, lua_Integer key, TValue *res) { */ const TValue *luaH_Hgetshortstr (Table *t, TString *key) { Node *n = hashstr(t, key); - lua_assert(key->tt == LUA_VSHRSTR); + lua_assert(strisshr(key)); for (;;) { /* check whether 'key' is somewhere in the chain */ if (keyisshrstr(n) && eqshrstr(keystrval(n), key)) return gval(n); /* that's it */ @@ -997,15 +997,6 @@ lu_byte luaH_getstr (Table *t, TString *key, TValue *res) { } -TString *luaH_getstrkey (Table *t, TString *key) { - const TValue *o = Hgetstr(t, key); - if (!isabstkey(o)) /* string already present? */ - return keystrval(nodefromval(o)); /* get saved copy */ - else - return NULL; -} - - /* ** main search function */ -- cgit v1.2.3-55-g6feb