Skip to content

Commit ff81a5d

Browse files
committed
Use the default capacity as the minimum for shrinking a HashTable
Remove un-needed default comparer
1 parent 9d7f71e commit ff81a5d

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

Algorithms/Sorters/Comparison/TimSorter.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public TimSorter(TimSorterSettings settings, IComparer<T> comparer)
8080
public void Sort(T[] array, IComparer<T> comparer)
8181
{
8282
ArgumentNullException.ThrowIfNull(array);
83-
this.comparer = comparer ?? Comparer<T>.Default;
8483

8584
var start = 0;
8685
var remaining = array.Length;

DataStructures/Hashing/HashTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public void Clear()
286286
public void Resize()
287287
{
288288
var newCapacity = size <= threshold / 2
289-
? capacity / 2
289+
? Math.Min(capacity / 2, DefaultCapacity)
290290
: capacity * 2;
291291
var newEntries = new Entry<TKey, TValue>[newCapacity];
292292

0 commit comments

Comments
 (0)