lua-users home
lua-l archive

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


At the expense of an API change, one could specify that lua_tostring take a
buffer which it can optionally fill with the string contents. The results of
tostring then only remain valid so long as the string is on the stack AND
the buffer is allocated.

Preserving the existing API from a call standpoint probably requires
changing the semantics of lua_tostring so that it only promises stability
for its result until the stack is modified.

But my concern on string speed has more to do with pushing table keys from C
code. A relatively large amount of work goes into finding the matching
existing string and this probably makes userdata less efficient than tables.
Maybe short strings would help there as well.

One other area where I've thought short strings might pay off is in the GC
since they wouldn't need to be traced.

Mark