Skip to content

Commit e7de977

Browse files
author
Andy
authored
Merge pull request #10754 from Microsoft/source_file
Optimize 'getSourceFile' to only get the source file once.
2 parents a612d58 + cae5bbb commit e7de977

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/services/services.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ namespace ts {
9191
}
9292

9393
public getText(sourceFile?: SourceFile): string {
94-
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
94+
if (!sourceFile) {
95+
sourceFile = this.getSourceFile();
96+
}
97+
return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd());
9598
}
9699

97100
private addSyntheticNodes(nodes: Node[], pos: number, end: number, useJSDocScanner?: boolean): number {

0 commit comments

Comments
 (0)