[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Newbie questions regarding luasocket, tables
- From: roberto@... (Roberto Ierusalimschy)
- Date: Tue, 8 May 2007 14:36:00 -0300
> Wouldn't it be easy, and very low-overhead, to increment and decrement a
> count for every add/remove? My countpairs() is O(n) :-(
I don't think so. Each assignment to a table can potentially add or
remove an element, depending on whether the old and the new values are
nil or not. Moreover, the counter would increase the basic size of a
table. I mean, it is not a big overhead, but not so insignificant to be
paid by every program that do not use this specific functionality.
(Usually, most single needs have a simple, low-overhead, and quite
efficient way to be implemented directly in Lua. But if we add each one
of them to the language, the final result will be neither simple nor
efficient.)
-- Roberto