fix garbage in FilterSignature.Equals

pull/4/head
cosmonaut 2023-04-05 12:08:24 -07:00
parent ca912a3b5a
commit 5f0d694eb4
2 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<Platforms>x64</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

View File

@ -21,7 +21,25 @@ namespace MoonTools.ECS
public bool Equals(FilterSignature other)
{
return Included.SetEquals(other.Included) && Excluded.SetEquals(other.Excluded);
// workaround for HashSet<T>.SetEquals generating garbage
// maybe fixed in .NET 8?
foreach (var included in Included)
{
if (!other.Included.Contains(included))
{
return false;
}
}
foreach (var excluded in Excluded)
{
if (!other.Excluded.Contains(excluded))
{
return false;
}
}
return true;
}
public override int GetHashCode()