Caching last used table index
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Caching last used table index
- From: "Soni \"They/Them\" L." <fakedme@...>
- Date: Sun, 5 May 2019 00:04:48 -0300
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?