Fixed bug in Listers.Things causing slowdowns and rarely errors in large colonies
Requires updated Fishery
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user