Fixed bug in Listers.Things causing slowdowns and rarely errors in large colonies

Requires updated Fishery
This commit is contained in:
bbradson
2024-04-28 20:19:36 +02:00
parent 91d664ddb7
commit 052425a1f0
6 changed files with 12 additions and 2 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<RootNamespace>PerformanceFish</RootNamespace>
<AssemblyName>PerformanceFish</AssemblyName>
<Authors>bradson</Authors>
<Version>0.6.0.1</Version>
<Version>0.6.1.0</Version>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<TargetFramework>net48</TargetFramework>
<LangVersion>preview</LangVersion>
+11 -1
View File
@@ -560,7 +560,17 @@ public sealed class Things : ClassWithFishPatches
public readonly FishTable<Type, IList> ThingsByType = new()
{
ValueInitializer = static type
=> (IList)Activator.CreateInstance(typeof(IndexedFishSet<>).MakeGenericType(type))
=> (IList)_thingsListInitializerDefinition.MakeGenericMethod(type).Invoke(null, null)
};
private static readonly MethodInfo _thingsListInitializerDefinition
= methodof(InitializeThingsList<Thing>).GetGenericMethodDefinition();
public static unsafe IndexedFishSet<T> InitializeThingsList<T>() where T : Thing
#pragma warning disable CS8622
=> new(static () => new(0, keyHashCodeByRefGetter: &GetKeyByRef, keyHashCodeGetter: &ThingHelper.GetKey));
#pragma warning restore CS8622
private static int GetKeyByRef<T>(ref T thing) where T : Thing => thing.GetKey();
}
}