Skip to content

Commit

Permalink
Use concurrent dictionary in related extensions calculation(#5951)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkolev92 committed Aug 6, 2024
1 parent e9b7d1c commit c6b57e4
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -14,8 +15,7 @@ public class ContentItemCollection
private static readonly ReadOnlyMemory<char> Winmd = ".winmd".AsMemory();

private List<Asset> _assets;
private Dictionary<ReadOnlyMemory<char>, string> _assemblyRelatedExtensions;

private ConcurrentDictionary<ReadOnlyMemory<char>, string> _assemblyRelatedExtensions;
/// <summary>
/// True if lib/contract exists
/// </summary>
Expand Down Expand Up @@ -309,14 +309,14 @@ internal string GetRelatedFileExtensionProperty(string assemblyPath, IEnumerable
// If no related files found.
if (relatedFileExtensionList is null || relatedFileExtensionList.Count == 0)
{
_assemblyRelatedExtensions[assemblyPrefix] = null;
_assemblyRelatedExtensions.TryAdd(assemblyPrefix, null);
return null;
}
else
{
relatedFileExtensionList.Sort();
string relatedFileExtensionsProperty = string.Join(";", relatedFileExtensionList);
_assemblyRelatedExtensions[assemblyPrefix] = relatedFileExtensionsProperty;
_assemblyRelatedExtensions.TryAdd(assemblyPrefix, relatedFileExtensionsProperty);
return relatedFileExtensionsProperty;
}

Expand Down

0 comments on commit c6b57e4

Please sign in to comment.