lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hugo Musso Gualandi <> 于2020年12月23日周三 上午4:21写道:
> > I think using a pointer to hold the string data would be better then
> > putting the data into a continuous TString structure.
> One advantage of putting the string data in a contiguous structure is that it avoids having to go through an additional layer of pointer indirection to read the string contents.
> But to be honest, I don't know how much that matters in practice. That's an interesting question.

In my opinion, the string object in lua VM core is only a reference.
We seldom use long-string as a key of the table,
and to the short-string key, lua doesn't need to read the string
contents. It only compares the pointers of TString.

A smaller GCObject is more (cache) friendly to the collector because
it always traverses the objects.