[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua 5 and tags
- From: Jamie Webb <j@...>
- Date: Sun, 25 Jul 2004 18:47:40 +0100
On Sun, Jul 25, 2004 at 02:39:01PM -0300, Alex Sandro Queiroz e Silva wrote:
> Hallo,
>
> Mark Hamburg wrote:
> >The Lua 5 approach is somewhat less efficient than one might like. If
> >efficiency is a concern, there are a variety of things one can do:
> >
> >* Rather than using strings to identify types, use light userdata. This
> >assumes that you have some permanent address to use for this purpose. This
> >will avoid some string manipulation when doing type-testing.
> >
>
> But in Lua a string comparison is just a pointer comparison, isn't
> it?
Yes, but when testing a string on the C-side, you either have to use
strcmp or obtain a Lua string to test against from the registry
or somesuch. For short strings, strcmp would be faster.
Actually, you can just store the address of the Lua string in C, and
as long as you ensure that the string isn't garbage-collected, the
address won't change. That behaviour isn't specced though, and is
functionally the same as using light userdata.
-- Jamie Webb