Skip to content

Commit 9c867e3

Browse files
Avoid allocation during binary expression emit when unnecessary.
1 parent e9874a2 commit 9c867e3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/compiler/emitter.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,13 +3109,12 @@ module ts {
31093109
//
31103110
// So we only indent if the right side of the binary expression starts further in on the line
31113111
// versus the left.
3112-
var operatorEnd = getLineAndCharacterOfPosition(currentSourceFile, node.operatorToken.end);
3113-
var rightStart = getLineAndCharacterOfPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.right.pos));
31143112

31153113
// Check if the right expression is on a different line versus the operator itself. If so,
31163114
// we'll emit newline.
3117-
var onDifferentLine = operatorEnd.line !== rightStart.line;
3118-
if (onDifferentLine) {
3115+
if (!nodeEndIsOnSameLineAsNodeStart(node.operatorToken, node.right)) {
3116+
var rightStart = getLineAndCharacterOfPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.right.pos));
3117+
31193118
// Also, if the right expression starts further in on the line than the left, then we'll indent.
31203119
var exprStart = getLineAndCharacterOfPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
31213120
var firstCharOfExpr = getFirstNonWhitespaceCharacterIndexOnLine(exprStart.line);

0 commit comments

Comments
 (0)