Merge pull request #10754 from Microsoft/source_file

Optimize 'getSourceFile' to only get the source file once.
This commit is contained in:
Andy 2016-09-13 14:02:39 -07:00 committed by GitHub
commit e7de977b90

View File

@ -91,7 +91,10 @@ namespace ts {
}
public getText(sourceFile?: SourceFile): string {
return (sourceFile || this.getSourceFile()).text.substring(this.getStart(), this.getEnd());
if (!sourceFile) {
sourceFile = this.getSourceFile();
}
return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd());
}
private addSyntheticNodes(nodes: Node[], pos: number, end: number, useJSDocScanner?: boolean): number {