aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-12-17 11:23:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2024-12-17 11:23:22 -0300
commit1c40ff9faafed620aa0458b397bcbfbe19e0f663 (patch)
treeedfb96022feb99244a7a6c4c9d28525e141b783e /ltable.c
parent7538f3886dfa091d661c56e48ebb1578ced8e467 (diff)
downloadlua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.tar.gz
lua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.tar.bz2
lua-1c40ff9faafed620aa0458b397bcbfbe19e0f663.zip
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.
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c11
1 files changed, 1 insertions, 10 deletions
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) {
962*/ 962*/
963const TValue *luaH_Hgetshortstr (Table *t, TString *key) { 963const TValue *luaH_Hgetshortstr (Table *t, TString *key) {
964 Node *n = hashstr(t, key); 964 Node *n = hashstr(t, key);
965 lua_assert(key->tt == LUA_VSHRSTR); 965 lua_assert(strisshr(key));
966 for (;;) { /* check whether 'key' is somewhere in the chain */ 966 for (;;) { /* check whether 'key' is somewhere in the chain */
967 if (keyisshrstr(n) && eqshrstr(keystrval(n), key)) 967 if (keyisshrstr(n) && eqshrstr(keystrval(n), key))
968 return gval(n); /* that's it */ 968 return gval(n); /* that's it */
@@ -997,15 +997,6 @@ lu_byte luaH_getstr (Table *t, TString *key, TValue *res) {
997} 997}
998 998
999 999
1000TString *luaH_getstrkey (Table *t, TString *key) {
1001 const TValue *o = Hgetstr(t, key);
1002 if (!isabstkey(o)) /* string already present? */
1003 return keystrval(nodefromval(o)); /* get saved copy */
1004 else
1005 return NULL;
1006}
1007
1008
1009/* 1000/*
1010** main search function 1001** main search function
1011*/ 1002*/