Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use concurrent dictionary in related extensions calculation #5951

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading