lua-users home
lua-l archive

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


Tomas Lundell <tomas.lundell@gmail.com> writes:

>     Please, do not refer to the "array part" or the "hash part" of a
>     table,
>     unless you are discussing the implementation of tables. They are
>     completely invisible (except for performance).
>     
>     -- Roberto
>     
>     
>
> I have personally replaced the Lua table implementation with an
> single-mechanism array-based hash table to reduce branching and memory
> consumption. Apart from serving as a hash table, when a table is used
> only as an array, the data structure will look like one automatically
> (a tight array of ordered numbers). Naturally, from the outside the
> language appears unchanged.

If I understand correctly, basically numbers hash to themselves in that
scheme.  The problem I see is that you lose efficiency for sequential
access when hashing more than just numbers, since the numbers then
compete with the non-numbers for hash buckets.

-- 
David Kastrup