Skip to content

Commit df4ab08

Browse files
committed
Merge pull request microsoft#8829 from Microsoft/tslintPerf
add a extra check to avoid rescans in Node.getStart
2 parents e5ed375 + b3531b0 commit df4ab08

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

scripts/tslint/booleanTriviaRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
1818

1919
visitCallExpression(node: ts.CallExpression) {
2020
super.visitCallExpression(node);
21-
if (node.arguments) {
21+
if (node.arguments && node.arguments.some(arg => arg.kind === ts.SyntaxKind.TrueKeyword || arg.kind === ts.SyntaxKind.FalseKeyword)) {
2222
const targetCallSignature = this.checker.getResolvedSignature(node);
2323
if (!!targetCallSignature) {
2424
const targetParameters = targetCallSignature.getParameters();

src/services/utilities.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ namespace ts {
267267
// find the child that contains 'position'
268268
for (let i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
269269
const child = current.getChildAt(i);
270+
if (position < child.getFullStart() || position > child.getEnd()) {
271+
continue;
272+
}
270273
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
271274
if (start <= position) {
272275
const end = child.getEnd();

0 commit comments

Comments
 (0)