Skip to content

Commit 58558d7

Browse files
committed
nit
1 parent a4b53f5 commit 58558d7

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Shared/Dictionary/SmallCapacityDictionary.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,27 @@ public static SmallCapacityDictionary<TKey, TValue> FromArray(KeyValuePair<TKey,
9898
/// Creates an empty <see cref="SmallCapacityDictionary{TKey, TValue}"/>.
9999
/// </summary>
100100
public SmallCapacityDictionary()
101-
: this(EqualityComparer<TKey>.Default, 0)
101+
: this(0, EqualityComparer<TKey>.Default)
102102
{
103103
}
104104

105105
public SmallCapacityDictionary(Dictionary<TKey, TValue> dict)
106-
: this(EqualityComparer<TKey>.Default, 0)
106+
: this(0, EqualityComparer<TKey>.Default)
107107
{
108108
_backup = dict;
109109
}
110110

111111
public SmallCapacityDictionary(IEqualityComparer<TKey> comparer)
112-
: this(comparer, 0)
112+
: this(0, comparer)
113113
{
114114
}
115115

116116
public SmallCapacityDictionary(int capacity)
117-
: this(EqualityComparer<TKey>.Default, capacity)
117+
: this(capacity, EqualityComparer<TKey>.Default)
118118
{
119119
}
120120

121-
public SmallCapacityDictionary(IEqualityComparer<TKey> comparer, int capacity)
121+
public SmallCapacityDictionary(int capacity, IEqualityComparer<TKey> comparer)
122122
{
123123
if (comparer is not null && comparer != EqualityComparer<TKey>.Default) // first check for null to avoid forcing default comparer instantiation unnecessarily
124124
{
@@ -157,7 +157,7 @@ public SmallCapacityDictionary(IEqualityComparer<TKey> comparer, int capacity)
157157
/// property names are keys, and property values are the values, and copied into the dictionary.
158158
/// Only public instance non-index properties are considered.
159159
/// </remarks>
160-
public SmallCapacityDictionary(IEnumerable<KeyValuePair<TKey, TValue>> values, IEqualityComparer<TKey> comparer = null, int capacity = 0)
160+
public SmallCapacityDictionary(IEnumerable<KeyValuePair<TKey, TValue>> values, IEqualityComparer<TKey> comparer, int capacity)
161161
{
162162
_comparer = comparer ?? EqualityComparer<TKey>.Default;
163163

@@ -181,7 +181,7 @@ public TValue this[TKey key]
181181

182182
TryGetValue(key, out var value);
183183

184-
return value;
184+
return value!;
185185
}
186186

187187
set

src/Shared/test/Shared.Tests/SmallCapacityDictionaryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void CreateFromIEnumerableKeyValuePair_CopiesValues()
8989
public void CreateFromIEnumerableStringValuePair_CopiesValues()
9090
{
9191
// Arrange & Act
92-
var dict = new SmallCapacityDictionary<string, string>(IEnumerableStringValuePairData);
92+
var dict = new SmallCapacityDictionary<string, string>(IEnumerableStringValuePairData, StringComparer.OrdinalIgnoreCase, capacity: 3);
9393

9494
// Assert
9595
Assert.IsType<KeyValuePair<string, string>[]>(dict._arrayStorage);
@@ -126,7 +126,7 @@ public void CreateFromIEnumerableStringValuePair_ThrowsExceptionForDuplicateKey(
126126

127127
// Act & Assert
128128
ExceptionAssert.ThrowsArgument(
129-
() => new SmallCapacityDictionary<string, string>(values, StringComparer.OrdinalIgnoreCase),
129+
() => new SmallCapacityDictionary<string, string>(values, StringComparer.OrdinalIgnoreCase, capacity: 3),
130130
"key",
131131
$"An element with the key 'Name' already exists in the {nameof(SmallCapacityDictionary<string, object>)}.");
132132
}

0 commit comments

Comments
 (0)