[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Using Lua's string interning for faster compares?
- From: HyperHacker <hyperhacker@...>
- Date: Tue, 17 Jan 2012 17:46:53 -0700
On Tue, Jan 17, 2012 at 17:42, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> > So we can rely on this behaviour and safely compare the pointer
>> > instead of the string itself?
>>
>> Yes, but you have to make sure that the strings still exist in Lua,
>> that is, are not collected. One way to do that is to use them as keys
>> or values in a table.
>
> To be 'religious' about the specification, you should not use a string
> pointer unless the string is anchored in the stack. But I guess it is
> quite safe to do the above in current implementations.
>
> -- Roberto
>
The registry table wouldn't be suitable for this?
--
Sent from my toaster.