lua-users home
lua-l archive

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


Pre-registered = put them in the registry.

Instead of:
    
    lua_pushliteral( L, "myString" );

Use something like the following (probably wrapped in subroutines):

    static int sRegIndex = LUA_NOREF;

    if( sRegIndex == LUA_NOREF ) {
        lua_pushliteral( L, "myString" );
        lua_pushvalue( L, -1 ); // dup
        sRegIndex = lua_ref( L, 1 );
    } else {
        lua_getref( L, sRegIndex );
    }

This way we only process "myString" once to convert it into a Lua string.

Mark

on 9/27/03 3:53 PM, Ando Sonenblick at ando@spritec.com wrote:

> 
> On Thursday, September 25, 2003, at 09:18 AM, Mark Hamburg wrote:
> 
>> My guess would
>> be that for the code you wrote, it would be better to do the table
>> indexing
>> in Lua since lua_pushliteral has to find the corresponding Lua string.
>> If
>> you pre-registered the strings -- or registered them on your first
>> pass --
>> you could avoid that issue.
> 
> Preregistered?   I havent come across preregistering strings.  Can you
> tell me about it (or send me to a page about it)?
> 
> thx,
> ando
> 
> 
> -----------------------
> Ando Sonenblick
> SpriTec Software
> www.spritec.com
>