Eliminate unnecessary LU_TAG_COUNT

This commit is contained in:
Petri Häkkinen 2023-11-29 10:14:47 +02:00
parent 9301d7fe11
commit cc57a0afb2
3 changed files with 9 additions and 5 deletions

View file

@ -84,7 +84,6 @@ typedef struct lua_TValue
// Internal tags used by the VM // Internal tags used by the VM
#define LU_TAG_ITERATOR LUA_UTAG_LIMIT #define LU_TAG_ITERATOR LUA_UTAG_LIMIT
#define LU_TAG_COUNT (LU_TAG_ITERATOR+1)
/* /*
** for internal debug only ** for internal debug only

View file

@ -197,7 +197,7 @@ typedef struct global_State
struct Table* mt[LUA_T_COUNT]; // metatables for basic types struct Table* mt[LUA_T_COUNT]; // metatables for basic types
TString* ttname[LUA_T_COUNT]; // names for basic types TString* ttname[LUA_T_COUNT]; // names for basic types
TString* tmname[TM_N]; // array with tag-method names TString* tmname[TM_N]; // array with tag-method names
TString* lightuserdataname[LU_TAG_COUNT]; // names for tagged lightuserdata TString* lightuserdataname[LUA_LUTAG_LIMIT]; // names for tagged lightuserdata
TValue pseudotemp; // storage for temporary values used in pseudo2addr TValue pseudotemp; // storage for temporary values used in pseudo2addr

View file

@ -131,10 +131,15 @@ const TString* luaT_objtypenamestr(lua_State* L, const TValue* o)
} }
else if (ttislightuserdata(o)) else if (ttislightuserdata(o))
{ {
const TString* name = L->global->lightuserdataname[lightuserdatatag(o)]; int tag = lightuserdatatag(o);
if (name) if (unsigned(tag) < LUA_LUTAG_LIMIT)
return name; {
const TString* name = L->global->lightuserdataname[tag];
if (name)
return name;
}
} }
else if (Table* mt = L->global->mt[ttype(o)]) else if (Table* mt = L->global->mt[ttype(o)])
{ {