lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 3/31/08, Mike Pall <mikelu-0803@mike.de> wrote:
> Shmuel Zeigerman wrote:
>  > Mike Pall wrote:
>  >> If you're storing all your userdatas in the array part, a simple
>  >> 't.foo = nil' triggers the shrinking. If you'r storing them in
>  >> the hash part, a 't[1] = nil' will do.
>  >
>  > My userdatas are keys in a weak keyed table. I've just tried your recipe in
>  > my application, both with t.foo=nil and with t[1]=nil -- it didn't help.
>
>
> Ooops, the 't[1] = nil' advice was wrong. This doesn't force
>  creation of the array part (which would trigger resizing). :-(
>

How about the following:

t[1]= true -- trigger resizing
t[1]= nil   -- remove, so that the trick will work next time

--Leo--