[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.concat - why so complex?
- From: Gavin Wraith <gavin@...>
- Date: Tue, 06 Apr 2010 14:56:14 +0100
In message <o2va41ac0b61004060624t18568273v4691c46a10e83ae3@mail.gmail.com>
you wrote:
> > You are presuming that Lua strings are stored in arrays, as a consecutive
> > sequence of bytes, as in C. They are not.
>
> Well colour me confused, as I was fairly certain that they were. At
> the API level, lua_pushlstring receives an array of bytes and
> lua_tolstring returns a (null terminated) array of bytes. I'm fairly
> certain that internally, strings are stored as a TString structure
> immediately followed in memory by a (null terminated) immutable array
> of bytes. There is the string hash table which allows for quick lookup
> of strings as to avoid creating the same string twice, but from the
> looks of it, the actual TString structures do not move, and so the
> "location" of a Lua string seems to be fairly well defined.
Apologies for my vague and misleading statement. Could it be rescued
if amended to "that is not all they are"?
If after the concatenated string has been built up in the buffer,
it turns out during the hash-calculation stage that the result
already exists, then the buffer is presumably thrown away?
--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/