From 65297cde19b319b556617f5afa70056e8129aca4 Mon Sep 17 00:00:00 2001 From: Andrius Date: Sat, 10 Aug 2019 18:03:50 +0300 Subject: [PATCH] perf(language-service): improve Language service performance (#32098) PR Close #32098 --- .../compiler/src/aot/static_symbol_resolver.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/compiler/src/aot/static_symbol_resolver.ts b/packages/compiler/src/aot/static_symbol_resolver.ts index 959f973a33..4d444723e4 100644 --- a/packages/compiler/src/aot/static_symbol_resolver.ts +++ b/packages/compiler/src/aot/static_symbol_resolver.ts @@ -273,13 +273,7 @@ export class StaticSymbolResolver { // Note: Some users use libraries that were not compiled with ngc, i.e. they don't // have summaries, only .d.ts files, but `summaryResolver.isLibraryFile` returns true. this._createSymbolsOf(filePath); - const metadataSymbols: StaticSymbol[] = []; - this.resolvedSymbols.forEach((resolvedSymbol) => { - if (resolvedSymbol.symbol.filePath === filePath) { - metadataSymbols.push(resolvedSymbol.symbol); - } - }); - return metadataSymbols; + return this.symbolFromFile.get(filePath) || []; } private _createSymbolsOf(filePath: string) { @@ -363,9 +357,12 @@ export class StaticSymbolResolver { this.createResolvedSymbol(symbol, filePath, topLevelSymbolNames, symbolMeta)); }); } - resolvedSymbols.forEach( - (resolvedSymbol) => this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol)); - this.symbolFromFile.set(filePath, resolvedSymbols.map(resolvedSymbol => resolvedSymbol.symbol)); + const uniqueSymbols = new Set(); + for (const resolvedSymbol of resolvedSymbols) { + this.resolvedSymbols.set(resolvedSymbol.symbol, resolvedSymbol); + uniqueSymbols.add(resolvedSymbol.symbol); + } + this.symbolFromFile.set(filePath, Array.from(uniqueSymbols)); } private createResolvedSymbol(