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
+18
View File
@@ -636,6 +636,24 @@ public static class CollectionExtensions
return destination;
}
public static unsafe void Fill<T>(this T[] array, T value)
{
Guard.IsNotNull(array);
if (array.Length == 0)
return;
fixed (T* startAddress = &array[0])
{
var i = array.Length - 1;
do
{
startAddress[i] = value;
}
while (--i >= 0);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void AddRangeFast<T>(this List<T> list, T[] range)
{