LiveScript
LiveScript copied to clipboard
Destructure assignment optimization
For example, this expression:
{item1, item2} = o = new CustomObject!
compiles to this code:
ref$ = o = new CustomObject(), item1 = ref$.item1, item2 = ref$.item2;
but could be:
o = new CustomObject(), item1 = o.item1, item2 = o.item2;
as the new object is already assigned to o
, additional reference variable is not needed.
do you agree?
Yes, I think I do agree. We'll have to be careful, though, about cases like
{a: o, b} = o = f!
which still require the ref$
variable.
I'll be careful, i promise :]