Fixed ArrayTypeMismatchException thrown on FishSets and Tables with certain reference type default values

This commit is contained in:
bbradson
2024-04-15 05:26:49 +02:00
parent 8d23bff6ba
commit 040a756d2e
12 changed files with 26 additions and 8 deletions
+3 -3
View File
@@ -266,7 +266,7 @@ public class FishTable<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, I
// Mathf.NextPowerOfTwo(minimumCapacity);
_buckets = new Entry[minimumCapacity];
Array.Fill(_buckets, _defaultEntry);
_buckets.Fill(_defaultEntry);
_tails = new((uint)minimumCapacity);
_bucketBitShift = 32 - FishMath.TrailingZeroCount((uint)_buckets.Length);
_wrapAroundMask = _buckets.Length - 1;
@@ -657,7 +657,7 @@ public class FishTable<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, I
_tails = new((uint)newSize);
_buckets = new Entry[newSize];
Array.Fill(_buckets, _defaultEntry);
_buckets.Fill(_defaultEntry);
_bucketBitShift = 32 - FishMath.TrailingZeroCount((uint)newSize);
_wrapAroundMask = _buckets.Length - 1;
@@ -1298,7 +1298,7 @@ public class FishTable<TKey, TValue> : IDictionary<TKey, TValue>, IDictionary, I
if (_buckets is null)
Initialize();
Array.Fill(_buckets, _defaultEntry);
_buckets.Fill(_defaultEntry);
_tails.Reset();
_count = 0;