[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Memory usage stats for 5.2 vs 5.3
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 14 Jan 2015 10:31:33 -0200
> [...] That said, a big +1 from me for removing those
> additional 4 bytes (from TString.hnext) in Lua 5.3 :)
I think we can do that following Tom's idea of storing the length of
short strings in a byte. Long strings are not hashed, so they do not
need the 'hnext' field. The struct could look like this:
typedef struct TString {
CommonHeader;
lu_byte extra; /* reserved words for short strings; "has hash" for longs */
lu_byte shtlen; /* length for short strings */
unsigned int hash;
union {
size_t len; /* length for long string */
struct TString *hnext; /* linked list for hash (only for short strings) */
} u;
} TString;
-- Roberto