Re: Function to force table to shrink?
Roberto Ierusalimschy <[email protected]>
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
> Okay, so a `clear` algorithm could: > > * set all keys returned by pairs() to nil > * set any key (i.e. t.a) to any value, then back to nil. > > The table will then be effectively clear. Unfortunately, it is not that simple. You must add enough new keys to force a rehash. In the example I gave, the table had only integer keys, all in its array part, so the hash part was empty (no slots). One new element there was enough for a hehash. But other scenarios can be way more tricky. -- Roberto -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/20260203143601.GA16887%40arraial.inf.puc-rio.br.