Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5db809e

Browse files
committed
refactor($parse): merge ternary and ternaryFn methods
splitting the code into two chunks doesn't buy us anything and only makes the code harder to follow
1 parent f6aacb9 commit 5db809e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/ng/parse.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -502,14 +502,6 @@ Parser.prototype = {
502502
});
503503
},
504504

505-
ternaryFn: function(left, middle, right){
506-
return extend(function $parseTernaryFn(self, locals){
507-
return left(self, locals) ? middle(self, locals) : right(self, locals);
508-
}, {
509-
constant: left.constant && middle.constant && right.constant
510-
});
511-
},
512-
513505
binaryFn: function(left, fn, right, isBranching) {
514506
return extend(function $parseBinaryFn(self, locals) {
515507
return fn(self, locals, left, right);
@@ -615,14 +607,20 @@ Parser.prototype = {
615607
if ((token = this.expect('?'))) {
616608
middle = this.assignment();
617609
if ((token = this.expect(':'))) {
618-
// TODO(perf): merge ternary and ternaryFn?
619-
return this.ternaryFn(left, middle, this.assignment());
610+
var right = this.assignment();
611+
612+
return extend(function $parseTernary(self, locals){
613+
return left(self, locals) ? middle(self, locals) : right(self, locals);
614+
}, {
615+
constant: left.constant && middle.constant && right.constant
616+
});
617+
620618
} else {
621619
this.throwError('expected :', token);
622620
}
623-
} else {
624-
return left;
625621
}
622+
623+
return left;
626624
},
627625

628626
logicalOR: function() {

0 commit comments

Comments
 (0)