lua-users home
lua-l archive

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


have you benchmarked it?

also note that "if not x then x = y" can be written as "x = x or y"

On Sat, May 4, 2019 at 10:05 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?