Re: Lua strings as "atoms"???
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua strings as "atoms"???
- From: Rici Lake <lua@...>
- Date: 2005年5月17日 09:17:11 -0500
On 17-May-05, at 8:57 AM, Rici Lake wrote:
And I bet there are a few more pitfalls.
Possibly. But it might still be worth it.
One of the pitfalls of "short strings" is that it would require a
change in the way the lexer recognises reserved words. (All reserved
words are short.) Currently, the lexer uses an otherwise unused byte in
the string structure which holds the token type for the reserved word;
this avoids a lookup in a reserved word hash table (or direct
recognition of the reserved words through a state machine.) On the
other hand, the tokens read by the lexer have to be hashed into the
string intern table, so it's not actually avoiding a hash lookup
altogether; simply avoiding a second one. Since short strings would
never need to be hashed into the string intern table, this would not
necessarily be slower.
One of the big gains, on the assumption that Lua workspaces are full of
short strings (many of mine are, for example), would be reduced load on
the garbage collector. A short string would not even have to be marked,
and would not require either malloc()ing or free()ing. I think this
alone may be enough of a win to make it worthwhile. But we'd never know
unless someone tried it.
- References:
- C api changing values, mark joselli
- Re: C api changing values, Asko Kauppi
- Lua strings as "atoms"???, Chris Marrin
- Re: Lua strings as "atoms"???, Ben Sunshine-Hill
- Re: Lua strings as "atoms"???, Chris Marrin
- Re: Lua strings as "atoms"???, Rici Lake
- Re: Lua strings as "atoms"???, Chris Marrin
- Re: Lua strings as "atoms"???, Rici Lake
- Re: Lua strings as "atoms"???, Chris Marrin
- Re: Lua strings as "atoms"???, Rici Lake
- Re: Lua strings as "atoms"???, Mike Pall
- Re: Lua strings as "atoms"???, Rici Lake