From 24e9e4806856de6a8ead217288ca54d145c851c2 Mon Sep 17 00:00:00 2001 From: Lizq <626409368@qq.com> Date: Sun, 7 Jun 2026 16:21:43 +0800 Subject: [PATCH 1/2] Fix SparseArray capacity parameter in AddSparseArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Passing type.Id as capacity was incorrect — it should be the SparseSet's Capacity, matching how StructuralSparseSet does it. --- src/Arch/Buffer/SparseSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arch/Buffer/SparseSet.cs b/src/Arch/Buffer/SparseSet.cs index fe433392..e025ddcf 100644 --- a/src/Arch/Buffer/SparseSet.cs +++ b/src/Arch/Buffer/SparseSet.cs @@ -285,7 +285,7 @@ public int Create(in Entity entity) private void AddSparseArray(ComponentType type) { - Components[type.Id] = new SparseArray(type, type.Id); + Components[type.Id] = new SparseArray(type, Capacity); Used[UsedSize] = type.Id; UsedSize++; From 2cbe71a4b9edac83c898883c272b043e405b7114 Mon Sep 17 00:00:00 2001 From: Lizq <626409368@qq.com> Date: Sun, 7 Jun 2026 16:21:46 +0800 Subject: [PATCH 2/2] Remove redundant bounds check in BitSet.Any MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The extra loops over [min, _max) are dead code — if any bits are set in that range, _highestBit > 0, so the final return already yields false. --- src/Arch/Core/Utils/BitSet.cs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Arch/Core/Utils/BitSet.cs b/src/Arch/Core/Utils/BitSet.cs index a82c593a..ee98fb9c 100644 --- a/src/Arch/Core/Utils/BitSet.cs +++ b/src/Arch/Core/Utils/BitSet.cs @@ -246,14 +246,6 @@ public bool Any(BitSet other) } } - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i++) - { - if (bits[i] > 0) - { - return false; - } - } } else { @@ -270,15 +262,6 @@ public bool Any(BitSet other) } } - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i += _padding) - { - var vector = new Vector(_bits, i); - if (!Vector.EqualsAll(vector, Vector.Zero)) // Vectors are not zero bits[0] != 0 basically - { - return false; - } - } } return _highestBit <= 0;