Skip to content

Commit 3a2648c

Browse files
authored
Avoid redundant SourceRepository allocation on cache hit in CachingSourceProvider (#7132)
1 parent 73f2208 commit 3a2648c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/NuGet.Core/NuGet.Protocol/CachingSourceProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public SourceRepository CreateRepository(PackageSource source)
6464

6565
public SourceRepository CreateRepository(PackageSource source, FeedType type)
6666
{
67+
if (_cachedSources.TryGetValue(source.Source, out SourceRepository cached))
68+
{
69+
return cached;
70+
}
71+
6772
return _cachedSources.GetOrAdd(source.Source, new SourceRepository(source, _resourceProviders, type));
6873
}
6974

0 commit comments

Comments
 (0)