Expand description
String table and interned-string operations — port of lstring.c + lstring.h.
Provides two key abstractions:
-
LuaStringImpl: the Lua string value, stored as a reference-counted byte slice. Short strings (<= MAX_SHORT_LENbytes) are interned in the process-globalStringPool; long strings are heap-allocated on each creation and never interned. -
StringPool: the intern table for short strings, stored onGlobalState. Replaces the Cstringtablestruct, which used an open-addressing hash table with intrusive chaining throughTString.u.hnext. In Rust the intrusive chain is dropped; aHashMapprovides O(1) lookup and automatic rehashing. See PORT NOTE onStringPoolfor the full rationale.
The lstring.h header is merged into this module per PORTING.md §1.
§C source files
reference/lua-5.4.7/src/lstring.c(275 lines, 15 functions)reference/lua-5.4.7/src/lstring.h(57 lines; merged here)
Structs§
- LuaString
Impl - A Lua string: an immutable, reference-counted byte sequence.
- LuaUser
Data Impl - Full userdata: a GC-tracked object carrying a raw byte payload plus optional Lua user values and an optional metatable.
- String
Pool - Intern table for short Lua strings. Lives on
GlobalState.
Enums§
- String
Kind - Whether a Lua string is short (interned) or long (not interned).