From 1f4fa28fac9ad93ddcbb229e3e0abf28db00d7aa Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Wed, 23 Nov 2016 12:08:41 -0800 Subject: [PATCH] Revert "refactor(compiler): allow control of StaticSymbol lifetime (#12986)" This reverts commit 2ca67e1674f56a7d99d3535a79a6b6ab0c30b721. --- .../compiler/src/aot/static_reflector.ts | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/modules/@angular/compiler/src/aot/static_reflector.ts b/modules/@angular/compiler/src/aot/static_reflector.ts index e4792d4c1e..f07aa7e8d3 100644 --- a/modules/@angular/compiler/src/aot/static_reflector.ts +++ b/modules/@angular/compiler/src/aot/static_reflector.ts @@ -44,30 +44,12 @@ export interface StaticReflectorHost { moduleNameToFileName(moduleName: string, containingFile: string): string; } -/** - * A cache of static symbol used by the StaticReflector to return the same symbol for the - * same symbol values. - */ -export class StaticSymbolCache { - private cache = new Map(); - - get(declarationFile: string, name: string, members?: string[]): StaticSymbol { - const memberSuffix = members ? `.${ members.join('.')}` : ''; - const key = `"${declarationFile}".${name}${memberSuffix}`; - let result = this.cache.get(key); - if (!result) { - result = new StaticSymbol(declarationFile, name, members); - this.cache.set(key, result); - } - return result; - } -} - /** * A static reflector implements enough of the Reflector API that is necessary to compile * templates statically. */ export class StaticReflector implements ReflectorReader { + private staticSymbolCache = new Map(); private declarationCache = new Map(); private annotationCache = new Map(); private propertyCache = new Map(); @@ -76,11 +58,7 @@ export class StaticReflector implements ReflectorReader { private conversionMap = new Map any>(); private opaqueToken: StaticSymbol; - constructor( - private host: StaticReflectorHost, - private staticSymbolCache: StaticSymbolCache = new StaticSymbolCache()) { - this.initializeConversionMap(); - } + constructor(private host: StaticReflectorHost) { this.initializeConversionMap(); } importUri(typeOrFunc: StaticSymbol): string { const staticSymbol = this.findDeclaration(typeOrFunc.filePath, typeOrFunc.name, ''); @@ -247,7 +225,14 @@ export class StaticReflector implements ReflectorReader { * @param name the name of the type. */ getStaticSymbol(declarationFile: string, name: string, members?: string[]): StaticSymbol { - return this.staticSymbolCache.get(declarationFile, name, members); + const memberSuffix = members ? `.${ members.join('.')}` : ''; + const key = `"${declarationFile}".${name}${memberSuffix}`; + let result = this.staticSymbolCache.get(key); + if (!result) { + result = new StaticSymbol(declarationFile, name, members); + this.staticSymbolCache.set(key, result); + } + return result; } private resolveExportedSymbol(filePath: string, symbolName: string): StaticSymbol {