diff --git a/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj b/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj
index 32f97b137e678a..87cf0520f8616d 100644
--- a/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj
+++ b/src/libraries/System.Collections.Immutable/src/System.Collections.Immutable.csproj
@@ -67,10 +67,6 @@ The System.Collections.Immutable library is built-in as part of the shared frame
-
-
-
-
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
index cfde792bfc71f2..b8084c19d67e73 100644
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
+++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs
@@ -192,15 +192,13 @@ private static FrozenDictionary CreateFromDictionary
{
if (analysis.HashCount == 1)
{
- frozenDictionary = analysis.IgnoreCase
- ? new OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex)
- : new OrdinalStringFrozenDictionary_RightJustifiedSingleChar(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex);
+ var comparison = analysis.IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
+ frozenDictionary = new OrdinalStringFrozenDictionary_RightJustifiedSingleChar(keys, values, stringComparer, comparison, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex);
}
else
{
- frozenDictionary = analysis.IgnoreCase
- ? new OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount)
- : new OrdinalStringFrozenDictionary_RightJustifiedSubstring(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount);
+ var comparison = analysis.IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
+ frozenDictionary = new OrdinalStringFrozenDictionary_RightJustifiedSubstring(keys, values, stringComparer, comparison, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount);
}
}
}
@@ -217,15 +215,13 @@ private static FrozenDictionary CreateFromDictionary
{
if (analysis.HashCount == 1)
{
- frozenDictionary = analysis.IgnoreCase
- ? new OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex)
- : new OrdinalStringFrozenDictionary_LeftJustifiedSingleChar(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex);
+ var comparison = analysis.IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
+ frozenDictionary = new OrdinalStringFrozenDictionary_LeftJustifiedSingleChar(keys, values, stringComparer, comparison, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex);
}
else
{
- frozenDictionary = analysis.IgnoreCase
- ? new OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount)
- : new OrdinalStringFrozenDictionary_LeftJustifiedSubstring(keys, values, stringComparer, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount);
+ var comparison = analysis.IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
+ frozenDictionary = new OrdinalStringFrozenDictionary_LeftJustifiedSubstring(keys, values, stringComparer, comparison, analysis.MinimumLength, analysis.MaximumLengthDiff, analysis.HashIndex, analysis.HashCount);
}
}
}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleChar.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleChar.cs
index b2bb0bb97b1a6c..52d797e91cfbc4 100644
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleChar.cs
+++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleChar.cs
@@ -7,15 +7,19 @@ namespace System.Collections.Frozen
{
internal sealed class OrdinalStringFrozenDictionary_LeftJustifiedSingleChar : OrdinalStringFrozenDictionary
{
+ private StringComparison _comparison;
+
internal OrdinalStringFrozenDictionary_LeftJustifiedSingleChar(
string[] keys,
TValue[] values,
IEqualityComparer comparer,
+ StringComparison comparison,
int minimumLength,
int maximumLengthDiff,
int hashIndex)
: base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, 1)
{
+ _comparison = comparison;
}
// This override is necessary to force the jit to emit the code in such a way that it
@@ -23,7 +27,7 @@ internal OrdinalStringFrozenDictionary_LeftJustifiedSingleChar(
// remove this, or you'll tank performance.
private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
- private protected override bool Equals(string? x, string? y) => string.Equals(x, y);
+ private protected override bool Equals(string? x, string? y) => string.Equals(x, y, _comparison);
private protected override int GetHashCode(string s) => s[HashIndex];
}
}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive.cs
deleted file mode 100644
index 2bebf7e04c18f0..00000000000000
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections.Generic;
-
-namespace System.Collections.Frozen
-{
- internal sealed class OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive : OrdinalStringFrozenDictionary
- {
- internal OrdinalStringFrozenDictionary_LeftJustifiedSingleCharCaseInsensitive(
- string[] keys,
- TValue[] values,
- IEqualityComparer comparer,
- int minimumLength,
- int maximumLengthDiff,
- int hashIndex)
- : base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, 1)
- {
- }
-
- // This override is necessary to force the jit to emit the code in such a way that it
- // avoids virtual dispatch overhead when calling the Equals/GetHashCode methods. Don't
- // remove this, or you'll tank performance.
- private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
-
- private protected override bool Equals(string? x, string? y) => StringComparer.OrdinalIgnoreCase.Equals(x, y);
- private protected override int GetHashCode(string s) => s[HashIndex];
- }
-}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstring.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstring.cs
index 2812dde4f1027c..533b5403330b49 100644
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstring.cs
+++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstring.cs
@@ -7,16 +7,20 @@ namespace System.Collections.Frozen
{
internal sealed class OrdinalStringFrozenDictionary_LeftJustifiedSubstring : OrdinalStringFrozenDictionary
{
+ private StringComparison _comparison;
+
internal OrdinalStringFrozenDictionary_LeftJustifiedSubstring(
string[] keys,
TValue[] values,
IEqualityComparer comparer,
+ StringComparison comparison,
int minimumLength,
int maximumLengthDiff,
int hashIndex,
int hashCount)
: base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, hashCount)
{
+ _comparison = comparison;
}
// This override is necessary to force the jit to emit the code in such a way that it
@@ -24,7 +28,7 @@ internal OrdinalStringFrozenDictionary_LeftJustifiedSubstring(
// remove this, or you'll tank performance.
private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
- private protected override bool Equals(string? x, string? y) => string.Equals(x, y);
+ private protected override bool Equals(string? x, string? y) => string.Equals(x, y, _comparison);
private protected override int GetHashCode(string s) => Hashing.GetHashCodeOrdinal(s.AsSpan(HashIndex, HashCount));
}
}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive.cs
deleted file mode 100644
index 0aec2fbe80473c..00000000000000
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections.Generic;
-
-namespace System.Collections.Frozen
-{
- internal sealed class OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive : OrdinalStringFrozenDictionary
- {
- internal OrdinalStringFrozenDictionary_LeftJustifiedSubstringCaseInsensitive(
- string[] keys,
- TValue[] values,
- IEqualityComparer comparer,
- int minimumLength,
- int maximumLengthDiff,
- int hashIndex,
- int hashCount)
- : base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, hashCount)
- {
- }
-
- // This override is necessary to force the jit to emit the code in such a way that it
- // avoids virtual dispatch overhead when calling the Equals/GetHashCode methods. Don't
- // remove this, or you'll tank performance.
- private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
-
- private protected override bool Equals(string? x, string? y) => StringComparer.OrdinalIgnoreCase.Equals(x, y);
- private protected override int GetHashCode(string s) => Hashing.GetHashCodeOrdinal(s.AsSpan(HashIndex, HashCount));
- }
-}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleChar.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleChar.cs
index cb7ae5fda7b4d4..a8e6241a1a9357 100644
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleChar.cs
+++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleChar.cs
@@ -7,15 +7,19 @@ namespace System.Collections.Frozen
{
internal sealed class OrdinalStringFrozenDictionary_RightJustifiedSingleChar : OrdinalStringFrozenDictionary
{
+ private StringComparison _comparison;
+
internal OrdinalStringFrozenDictionary_RightJustifiedSingleChar(
string[] keys,
TValue[] values,
IEqualityComparer comparer,
+ StringComparison comparison,
int minimumLength,
int maximumLengthDiff,
int hashIndex)
: base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, 1)
{
+ _comparison = comparison;
}
// This override is necessary to force the jit to emit the code in such a way that it
@@ -23,7 +27,7 @@ internal OrdinalStringFrozenDictionary_RightJustifiedSingleChar(
// remove this, or you'll tank performance.
private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
- private protected override bool Equals(string? x, string? y) => string.Equals(x, y);
+ private protected override bool Equals(string? x, string? y) => string.Equals(x, y, _comparison);
private protected override int GetHashCode(string s) => s[s.Length + HashIndex];
}
}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive.cs
deleted file mode 100644
index b60fb38ae32405..00000000000000
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections.Generic;
-
-namespace System.Collections.Frozen
-{
- internal sealed class OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive : OrdinalStringFrozenDictionary
- {
- internal OrdinalStringFrozenDictionary_RightJustifiedSingleCharCaseInsensitive(
- string[] keys,
- TValue[] values,
- IEqualityComparer comparer,
- int minimumLength,
- int maximumLengthDiff,
- int hashIndex)
- : base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, 1)
- {
- }
-
- // This override is necessary to force the jit to emit the code in such a way that it
- // avoids virtual dispatch overhead when calling the Equals/GetHashCode methods. Don't
- // remove this, or you'll tank performance.
- private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
-
- private protected override bool Equals(string? x, string? y) => StringComparer.OrdinalIgnoreCase.Equals(x, y);
- private protected override int GetHashCode(string s) => s[s.Length + HashIndex];
- }
-}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstring.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstring.cs
index cd8fe0602ef7b5..5ea1465eb35f76 100644
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstring.cs
+++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstring.cs
@@ -7,16 +7,20 @@ namespace System.Collections.Frozen
{
internal sealed class OrdinalStringFrozenDictionary_RightJustifiedSubstring : OrdinalStringFrozenDictionary
{
+ private StringComparison _comparison;
+
internal OrdinalStringFrozenDictionary_RightJustifiedSubstring(
string[] keys,
TValue[] values,
IEqualityComparer comparer,
+ StringComparison comparison,
int minimumLength,
int maximumLengthDiff,
int hashIndex,
int hashCount)
: base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, hashCount)
{
+ _comparison = comparison;
}
// This override is necessary to force the jit to emit the code in such a way that it
@@ -24,7 +28,7 @@ internal OrdinalStringFrozenDictionary_RightJustifiedSubstring(
// remove this, or you'll tank performance.
private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
- private protected override bool Equals(string? x, string? y) => string.Equals(x, y);
+ private protected override bool Equals(string? x, string? y) => string.Equals(x, y, _comparison);
private protected override int GetHashCode(string s) => Hashing.GetHashCodeOrdinal(s.AsSpan(s.Length + HashIndex, HashCount));
}
}
diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive.cs
deleted file mode 100644
index 117d2f329ccf4b..00000000000000
--- a/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/String/OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System.Collections.Generic;
-
-namespace System.Collections.Frozen
-{
- internal sealed class OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive : OrdinalStringFrozenDictionary
- {
- internal OrdinalStringFrozenDictionary_RightJustifiedSubstringCaseInsensitive(
- string[] keys,
- TValue[] values,
- IEqualityComparer comparer,
- int minimumLength,
- int maximumLengthDiff,
- int hashIndex,
- int hashCount)
- : base(keys, values, comparer, minimumLength, maximumLengthDiff, hashIndex, hashCount)
- {
- }
-
- // This override is necessary to force the jit to emit the code in such a way that it
- // avoids virtual dispatch overhead when calling the Equals/GetHashCode methods. Don't
- // remove this, or you'll tank performance.
- private protected override ref readonly TValue GetValueRefOrNullRefCore(string key) => ref base.GetValueRefOrNullRefCore(key);
-
- private protected override bool Equals(string? x, string? y) => StringComparer.OrdinalIgnoreCase.Equals(x, y);
- private protected override int GetHashCode(string s) => Hashing.GetHashCodeOrdinal(s.AsSpan(s.Length + HashIndex, HashCount));
- }
-}