lua-users home
lua-l archive

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


This is why I like mandatory declarations:

On Wed, Sep 30, 2020 at 4:35 PM Francisco Olarte <folarte@peoplecall.com> wrote:
> > local s=os.time();local t={};t.a=1;for j=1,100000000 do t[-j]=nill end;print(os.time()-s)
> 6
> > local s=os.time();local t={};for j=1,100000000 do t[-j]=nill end;print(os.time()-s)
> 2
> > local s=os.time();local t={};t[0]=1;for j=1,100000000 do t[-j]=nill end;print(os.time()-s)
> 7
> > local s=os.time();local t={};t[1]=1;for j=1,100000000 do t[-j]=nill end;print(os.time()-s)
> 3

Of course on a just started interpreter nill==nil, anyway, I redid it
properly, similar results

> local s=os.time();local t={};for j=1,100000000 do t[-j]=nil end;print(os.time()-s)
2
> local s=os.time();local t={};t[0]=1;for j=1,100000000 do t[-j]=nil end;print(os.time()-s)
5
> local s=os.time();local t={};t[1]=1;for j=1,100000000 do t[-j]=nil end;print(os.time()-s)
2
> local s=os.time();local t={};t.a=1;for j=1,100000000 do t[-j]=nil end;print(os.time()-s)
6

Francisco "ChubbyFingers" Olarte.