lua-users home
lua-l archive

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


On Monday 28 February 2005 19:07, David Olofson wrote:
> > In a case like this, I use this:
> > 
> >  y = 2
> >  if a then  y = 1  end
> >
> > Only two, no 'else' and no chance of a var depending on a
> > conditional branch merely for its prior existence...
>
> Right, that's the universal solution; works with pretty much every
> language. The only problem is that it's kind of wasteful if the
> assignment is more expensive than loading a value into a register or
> similar.
tests showed this about equally fast as if..y=..else y=,
if a is false, and about 10% slower, if a is true
(all variables being local)