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.
This commit is contained in:
11
ltable.c
11
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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user