From 5f0d694eb47376ea057bfd99c54408de9bfb20f7 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 5 Apr 2023 12:08:24 -0700 Subject: [PATCH] fix garbage in FilterSignature.Equals --- MoonTools.ECS.csproj | 2 +- src/FilterSignature.cs | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/MoonTools.ECS.csproj b/MoonTools.ECS.csproj index 2f2b5e6..5cd9326 100644 --- a/MoonTools.ECS.csproj +++ b/MoonTools.ECS.csproj @@ -1,7 +1,7 @@ - net6.0;net7.0 + net7.0 enable x64 true diff --git a/src/FilterSignature.cs b/src/FilterSignature.cs index 8fd65ec..3877391 100644 --- a/src/FilterSignature.cs +++ b/src/FilterSignature.cs @@ -21,7 +21,25 @@ namespace MoonTools.ECS public bool Equals(FilterSignature other) { - return Included.SetEquals(other.Included) && Excluded.SetEquals(other.Excluded); + // workaround for HashSet.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()