[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Caching last used table index
- From: Tim Hill <drtimhill@...>
- Date: Sun, 5 May 2019 11:13:32 -0700
> On May 4, 2019, at 8:04 PM, Soni They/Them L. <fakedme@gmail.com> wrote:
>
> I often write code like:
>
> local foo = t.foo
> if not foo then foo = whatever t.foo = foo end
> -- use foo here
>
> but ideally I'd like to write it like:
>
> if not t.foo then t.foo = whatever end
> local foo = t.foo
>
> and still have the same performance (or better).
>
> does lua do any optimizations related to this?
>
Do you REALLY mean “if not foo…” ? Dont you actually want “if foo == nil …” ?
—Tim