[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: table.maxn...
- From: Javier Guerra Giraldez <javier@...>
- Date: Sat, 30 May 2015 23:40:20 -0500
On Sat, May 30, 2015 at 11:28 PM, Brigham Toskin
> Does anyone know the rationale for not just automatically tracking the
> number of entries in a table?
reliably tracking table size means at some point you need a linear
scan. Yes, i know at first sight it looks like it's just a +1 or -1
(or neither) on each table setting, but there's always some
not-uncommon case where you have to do a potentially-too-heavy
Table setting operations are too critical for _all_ Lua code to be
subject to that kind of overhead. Having a logarithmic (and
frequently resolved at the first step) operation at visible points of
your code seems a better compromise.