lua-users home
lua-l archive

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


> One of the other enhancements I have been thinking about for a while
> is to efficiently support aggregate types. Mainly the idea I have been
> playing around with is to implement such types using tables - but with
> numeric indices. The reason for using a numeric index is to help
> generate efficient code. For example a 'get' operation could be
> inlined thus:
> 
> if (l_castS2U(key - 1) < t->sizearray)
>     v = &t->array[key - 1];
> else
>     v = luaH_getint(t, key);
> 
> The problem with numeric indices is readability and error-proneness.
> [...]

Did you consider an inline expansion of short string keys? You could
do a loop unrolling of 'luaH_getstr'. (With 2 steps, I believe you
get a very high percentage of hits.) It is not the same as the
above expansion for integer keys, but it could be a reasonable
compromise.

-- Roberto