|
Ultimately, I think that it should also be reconsidered whether to shrink tables. Amortized O(1) newindex runtime doesn't need to be sacrificed; for example, what about shrinking tables once the load factor drops to less than one third?
No Lua implementation which uses hashtables as table implementation is able to shrink tables on GC or when changing existing properties as it would change a potential ongoing iteration over the table. It is also not possible to detect tables which are currently iterated over during GC and only resize those wo aren't.
However, when insering into tables the table can actually shrink (and it does so in PUC Lua) if the space required goes down when a rehash is triggered.
Regards, Xmilia