lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] wrote:
-- Sorry for the quick double post

I should have checked beforehand, but after poking around ltable.c it looks like
it's a design decision that tables are (almost) never shrunk.

The only reason it shrunk the array when the hash table was used in the example
was because the hash table had previously been unused - requiring it to grow and
reevaluate its array size. So it looks like you can't count on a table being
shrunk... I would be very interested to see a program in which this would be a
problem though. Most high speed allocators rarely shrink blocks anyway; even if

i can imagine that in the case of an indexed table, { 'a', 'b', nil, 'd' } actually is meaningfull, but as soon as one uses the table as a hash, it gets less meaningfull to keep the nils and so a cleanup makes sense then


                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 |