Issue #609. Slightly faster implementation of ||= and &&=

This commit is contained in:
Jeremy Ashkenas
2010-08-14 18:02:07 -04:00
parent f496cc229b
commit 975b82f09b
7 changed files with 30 additions and 30 deletions

View File

@@ -1121,7 +1121,7 @@ exports.OpNode = class OpNode extends BaseNode
second = "(#{second})" if @second instanceof OpNode
o.scope.find(first) if first.match(IDENTIFIER)
return "#{first} = #{ ExistenceNode.compileTest(o, literal(firstVar))[0] } ? #{firstVar} : #{second}" if @operator is '?='
"#{first} = #{firstVar} #{ @operator.substr(0, 2) } #{second}"
"#{first} #{ @operator.substr(0, 2) } (#{firstVar} = #{second})"
# If this is an existence operator, we delegate to `ExistenceNode.compileTest`
# to give us the safe references for the variables.