Skip to content

Commit

Permalink
optimized a !?= b
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Jun 14, 2011
1 parent 1bb3d89 commit c011941
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -1573,8 +1573,8 @@ exports.Assign = Assign = (function(_super){
return code;
};
prototype.compileConditional = function(o, left){
var lefts, morph;
if (this.logic === '?' && this.op === '=' && left instanceof Var) {
var lefts, morph, _ref;
if (left instanceof Var && ((_ref = this.logic) === '?' || _ref === '!?') && this.op === '=') {
o.scope.declare(left.value);
}
lefts = Chain(left).cacheReference(o);
Expand Down
2 changes: 1 addition & 1 deletion src/ast.co
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ class exports.Assign extends Node
code

compileConditional: (o, left) ->
if @logic is \? and @op is \= and left instanceof Var
if left instanceof Var and @logic of <[ ? !? ]> and @op is \=
o.scope.declare left.value
lefts = Chain(left)cacheReference o
morph = Op @logic, lefts.0, @<<<{-logic, left: lefts.1}
Expand Down

0 comments on commit c011941

Please sign in to comment.