lua-users home
lua-l archive

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


> Say, I want to write code that does '#' on value x. I can write:
> 
>    while #x do break end
>    do local _ = #x end
>    (function () return #x end)()
> 
> Is there something that has least runtime and size overhead,
> i.e. doesn't create extra branches or stack allocations in bytecode?

There's also
	repeat until #x
assuming (as you are) that #x does not return false...
 
But this generates the simplest bytecode:
	do local _ = #x end