From 7938ff34b171e4bbf362f39d9e6e2c8e1abf6486 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Thu, 5 Dec 2019 21:02:57 +0200 Subject: [PATCH] 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 --- .../src/ngtsc/partial_evaluator/src/interface.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interface.ts b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interface.ts index 1652ac1b33..76b3e56989 100644 --- a/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interface.ts +++ b/packages/compiler-cli/src/ngtsc/partial_evaluator/src/interface.ts @@ -26,10 +26,11 @@ export class PartialEvaluator { evaluate(expr: ts.Expression, foreignFunctionResolver?: ForeignFunctionResolver): ResolvedValue { const interpreter = new StaticInterpreter(this.host, this.checker, this.dependencyTracker); + const sourceFile = expr.getSourceFile(); return interpreter.visit(expr, { - originatingFile: expr.getSourceFile(), + originatingFile: sourceFile, absoluteModuleName: null, - resolutionContext: expr.getSourceFile().fileName, + resolutionContext: sourceFile.fileName, scope: new Map(), foreignFunctionResolver, }); }