fix(lua): pack TValue and TKey structs to reduce RAM usage (#7289)

This commit is contained in:
Raphael Coeffic
2026-04-27 10:01:27 +10:00
committed by GitHub
parent 7d15aa341f
commit ef3008bb37
+8 -10
View File
@@ -117,20 +117,18 @@ typedef union Value {
} Value; } Value;
#define TValuefields Value value_; int tt_ #define TValuefields Value value_; lu_byte tt_
// #ifdef LUA_USE_ESP #if defined(__GNUC__) || defined(__clang__)
// # pragma pack(4) #define LUA_PACKED __attribute__((__packed__))
// #endif #else
#define LUA_PACKED
#endif
typedef struct lua_TValue { typedef struct LUA_PACKED lua_TValue {
TValuefields; TValuefields;
} TValue; } TValue;
// #ifdef LUA_USE_ESP
// # pragma pack()
// #endif
/* macro defining a nil value */ /* macro defining a nil value */
#define NILCONSTANT {NULL}, LUA_TNIL #define NILCONSTANT {NULL}, LUA_TNIL
@@ -509,7 +507,7 @@ typedef union Closure {
*/ */
typedef union TKey { typedef union TKey {
struct { struct LUA_PACKED {
TValuefields; TValuefields;
int next; /* for chaining (offset for next node) */ int next; /* for chaining (offset for next node) */
} nk; } nk;