Skip to content

Commit 59657c7

Browse files
committed
Avoid dependency on List.Sort
1 parent 655733f commit 59657c7

File tree

2 files changed

+5
-4
lines changed
  • src
    • coreclr/System.Private.CoreLib/src/System
    • libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics

2 files changed

+5
-4
lines changed

src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ internal static RuntimeType[] GetMethodInstantiationInternal(RuntimeMethodHandle
12311231

12321232
internal static Type[]? GetMethodInstantiationPublic(IRuntimeMethodInfo method)
12331233
{
1234-
RuntimeType[]? types = null;
1234+
Type[]? types = null;
12351235
GetMethodInstantiation(EnsureNonNullMethodInfo(method).Value, ObjectHandleOnStack.Create(ref types), Interop.BOOL.FALSE);
12361236
GC.KeepAlive(method);
12371237
return types;

src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/Meter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using System.ComponentModel;
6+
using System.Collections.ObjectModel;
67
using System.Diagnostics;
78
using System.Diagnostics.CodeAnalysis;
89
using System.Threading;
@@ -78,9 +79,9 @@ private void Initialize(string name, string? version, IEnumerable<KeyValuePair<s
7879
Version = version;
7980
if (tags is not null)
8081
{
81-
var tagList = new List<KeyValuePair<string, object?>>(tags);
82-
tagList.Sort((left, right) => string.Compare(left.Key, right.Key, StringComparison.Ordinal));
83-
Tags = tagList.AsReadOnly();
82+
var tagList = new List<KeyValuePair<string, object?>>(tags).ToArray();
83+
Array.Sort(tagList, (left, right) => string.Compare(left.Key, right.Key, StringComparison.Ordinal));
84+
Tags = new ReadOnlyCollection<KeyValuePair<string, object?>>(tagList);
8485
}
8586
Scope = scope;
8687
TelemetrySchemaUrl = telemetrySchemaUrl;

0 commit comments

Comments
 (0)