Skip to content

Commit 390c617

Browse files
committed
cache decompiled SharpIdeFile
1 parent 0a8dc42 commit 390c617

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/SharpIDE.Application/Features/Analysis/SharpIdeMetadataAsSourceService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ namespace SharpIDE.Application.Features.Analysis;
66
public class SharpIdeMetadataAsSourceService(RoslynAnalysis roslynAnalysis)
77
{
88
private readonly RoslynAnalysis _roslynAnalysis = roslynAnalysis;
9+
private readonly Dictionary<string, SharpIdeFile> _metadataAsSourceFileCache = [];
910

1011
public async Task<SharpIdeFile?> CreateSharpIdeFileForMetadataAsSourceAsync(SharpIdeFile currentFile, ISymbol referencedSymbol)
1112
{
1213
var filePath = await _roslynAnalysis.GetMetadataAsSource(currentFile, referencedSymbol);
1314
if (filePath is null) return null;
15+
var fileFromCache = _metadataAsSourceFileCache.GetValueOrDefault(filePath);
16+
if (fileFromCache is not null) return fileFromCache;
1417
var metadataAsSourceSharpIdeFile = new SharpIdeFile(filePath, Path.GetFileName(filePath), Path.GetExtension(filePath), null!, [], true);
18+
_metadataAsSourceFileCache[filePath] = metadataAsSourceSharpIdeFile;
1519
return metadataAsSourceSharpIdeFile;
1620
}
1721
}

0 commit comments

Comments
 (0)