lua-users home
lua-l archive

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


On Sun, Sep 24, 2006 at 08:26:51PM -0500, Rici Lake wrote:
> 
> On 24-Sep-06, at 7:33 PM, Glenn Maynard wrote:
> >    iFreeListRef = ref;
> >    if(ref == iMaxReference)
> >        --iMaxReference;
> 
> I think that should be:
> 
>     if (ref == iMaxReference)
>         --iMaxReference;
>     else
>         iFreeListRef = ref;
> 
> Otherwise, you'll give out the same references twice.

The logic is the same as in lauxlib; it's just forming a linked list
of indexes, where iFreeListRef is the head.

> You may find it faster to nil out the reference table entry, and keep 
> the free list in your own private datastructure; it's possible that 
> your compiler is not generating good code for converting between 

I tried that, to reduce table accesses a bit more; the difference was
measurable but not very much.

> integer and floating point. (In general, you should use lua_pushinteger 

I just changed it to pushnumber for comparing 5.0 and 5.1; I didn't
see any difference.  (I think that, since Lua currently stores only
floats internally, it has to do the conversion either way.)

> with lua 5.1, I think.) You could also try storing the freelist indices 
> coerced to (void *) and wrapped as lightuserdata.

I tried a different approach with the same effect: storing the indexes
in a C++ vector, which gave maybe a 10% improvement, but still not bringing
it close to 5.0's speed, and also giving 5.0 a comparable speedup.

-- 
Glenn Maynard