lua-users home
lua-l archive

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


On 4 November 2015 at 21:08, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> On 3 November 2015 at 06:20, Dirk Laurie <dirk.laurie@gmail.com> wrote:
>>> local Employee : [] = { 'dibyendu', 'majumdar' }
>>>
>>> Above could be how an array of dynamic types is declared.
>>
>> What performance benefits do you see in static-typing an array but
>> not its entries?
>>
>
> The main idea is to be able to inline the code generated for GETTABLE
> and possibly SETTABLE. To do this the parser needs to know that the
> indexing is being done on a table, and the index is an integer.
>

BTW the cost compared to inline access is significant:

1) First luaV_gettable() is called.
2) This executes a loop.
3) Next check that the variable is a table.
4) If so call luaH_get().
5) luaH_get() checks that key type
6) If integer then calls luaH_getint()
Which finally executes the code that I would like to generate in step 1.

Regards