Fix for a conflicting patch with one or more of RimCities, Common Sense and Simple Sidearms

This commit is contained in:
bbradson
2024-02-01 23:00:04 +01:00
parent 949bde76ce
commit d394d31f05
5 changed files with 13 additions and 3 deletions
Binary file not shown.
Binary file not shown.
@@ -137,7 +137,7 @@ public sealed class ThingOwnerOptimization : ClassWithFishPrepatches
: innerList.LastIndexOf((T)item);
if (index >= 0)
innerList.RemoveAtFastUnordered(index);
innerList.RemoveAtFastUnorderedUnsafe(index);
indexMap.Remove(itemKey);
@@ -17,7 +17,7 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<Configurations>v1.4</Configurations>
<Version>0.3.999.9</Version>
<Version>0.3.999.91</Version>
<NoWarn>
1701;1702;IL2121;CS8500;CS9082;CA1000;CA1002;CA1003;CA1707;CA1010;CA1715;CA1716;CA1724;CA1031;CA1033;
CA1034;CA1043;CA1051;CA1305;CA1310;CA1710;CA1711;CA1810;CA1812;CA1819;CA1851;CA2002;CA5394;CA1725;CA1062
@@ -5,7 +5,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Mono.Collections.Generic;
namespace PerformanceFish.Utility;
@@ -296,6 +295,17 @@ public static class CollectionExtensions
return ThrowForNoElements<T>();
}
public static unsafe void RemoveAtFastUnorderedUnsafe<T>(this List<T> list, int index)
{
fixed (T* lastBucket = &list._items[list._size - 1])
{
list[index] = *lastBucket;
*lastBucket = default;
}
list._size--;
}
public static List<T> AsOrToList<T>(this IEnumerable<T> enumerable) => enumerable as List<T> ?? enumerable.ToList();