refactor(compiler-cli): avoid unnecessarily calling `getSourceFile()` twice in `PartialEvaluator` (#34441)

This is not expected to have any noticeable perf impact, but it wasteful
nonetheless (and annoying when stepping through the code while debugging
`ngtsc`/`ngcc`).

PR Close #34441
This commit is contained in:
George Kalpakas 2019-12-05 21:02:57 +02:00 committed by Kara Erickson
parent b637b9322e
commit 7938ff34b1
1 changed files with 3 additions and 2 deletions

View File

@ -26,10 +26,11 @@ export class PartialEvaluator {
evaluate(expr: ts.Expression, foreignFunctionResolver?: ForeignFunctionResolver): ResolvedValue { evaluate(expr: ts.Expression, foreignFunctionResolver?: ForeignFunctionResolver): ResolvedValue {
const interpreter = new StaticInterpreter(this.host, this.checker, this.dependencyTracker); const interpreter = new StaticInterpreter(this.host, this.checker, this.dependencyTracker);
const sourceFile = expr.getSourceFile();
return interpreter.visit(expr, { return interpreter.visit(expr, {
originatingFile: expr.getSourceFile(), originatingFile: sourceFile,
absoluteModuleName: null, absoluteModuleName: null,
resolutionContext: expr.getSourceFile().fileName, resolutionContext: sourceFile.fileName,
scope: new Map<ts.ParameterDeclaration, ResolvedValue>(), foreignFunctionResolver, scope: new Map<ts.ParameterDeclaration, ResolvedValue>(), foreignFunctionResolver,
}); });
} }