Skip to content

Commit 5c08fda

Browse files
Copilotjoelverhagen
andcommitted
Add static Instance property to NullableFrameworkComparer for caching
Co-authored-by: joelverhagen <[email protected]>
1 parent 70ce314 commit 5c08fda

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/NuGetGallery/ViewModels/DependencySetsViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public DependencySetsViewModel(IEnumerable<PackageDependency> packageDependencie
4949
}
5050

5151
// Sort by framework using NuGetFrameworkSorter, with null frameworks (All Frameworks) first
52-
var sortedGroups = frameworkGroups.OrderBy(g => g.framework, new NullableFrameworkComparer());
52+
var sortedGroups = frameworkGroups.OrderBy(g => g.framework, NullableFrameworkComparer.Instance);
5353

5454
// Build the final dictionary with friendly names
5555
foreach (var group in sortedGroups)
@@ -95,6 +95,8 @@ public DependencyViewModel(string id, string versionSpec)
9595

9696
private class NullableFrameworkComparer : IComparer<NuGetFramework>
9797
{
98+
public static readonly NullableFrameworkComparer Instance = new NullableFrameworkComparer();
99+
98100
public int Compare(NuGetFramework x, NuGetFramework y)
99101
{
100102
// Put "All Frameworks" (null) first

0 commit comments

Comments
 (0)