lua-users home
lua-l archive

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


Alexander Nasonov wrote:
> Mike Pall wrote:
> > There's no way to do that without traversing the whole table. All
> > shortcuts that try to infer something from e.g. #t or next() will
> > fail under some circumstances.
> 
> I think you only need to traverse a hash part and stop when you find
> a non-empty bucket. But you're right, that's still a linear search.

Sorry, I missed "without holes". In this case you need to traverse the
whole table.

If a total number of elements was tracked we could compare it for
equality with #t and serialize as array but counting element has a cost.

Alex