Skip to content

Commit 6c81f6a

Browse files
Remove all debug logging and restore production code
Cleaned up: - ResizeSystem.OnInit debug output - SimpleTest.cs debug Console.WriteLine statements - GroupResultEnumerator debug logging - Context.Archetypes GetMatchingArchetypes debug output - Tag.Equals debug logging and restored inlining attributes The actual fixes remain: 1. SimdOps.AreEqual: Fixed MoveMask comparison (0xFFFF not -1) 2. Tag.Equals: Handle null vs empty overflow arrays correctly
1 parent 0a567c5 commit 6c81f6a

5 files changed

Lines changed: 4 additions & 57 deletions

File tree

EasyEcs.Core/Components/Tag.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,39 +177,27 @@ private static Vector128<long>[] InvertOverflow(Vector128<long>[] overflow)
177177
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
178178
public static bool operator !=(Tag a, Tag b) => !a.Equals(b);
179179

180-
// Temporarily remove inlining for debugging
180+
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
181181
public bool Equals(in Tag other)
182182
{
183-
bool bits0Equal = SimdOps.AreEqual(_bits0, other._bits0);
184-
bool bits1Equal = SimdOps.AreEqual(_bits1, other._bits1);
185-
186-
if (!bits0Equal || !bits1Equal)
187-
{
188-
Console.WriteLine($"Tag.Equals: bits mismatch - bits0Equal={bits0Equal}, bits1Equal={bits1Equal}");
183+
if (!SimdOps.AreEqual(_bits0, other._bits0) || !SimdOps.AreEqual(_bits1, other._bits1))
189184
return false;
190-
}
191185

192186
// Handle overflow comparison - treat null and empty as equivalent
193187
int thisLen = _overflow?.Length ?? 0;
194188
int otherLen = other._overflow?.Length ?? 0;
195189
int maxLen = Math.Max(thisLen, otherLen);
196190

197-
Console.WriteLine($"Tag.Equals: bits match, checking overflow - thisLen={thisLen}, otherLen={otherLen}, maxLen={maxLen}");
198-
199191
// If one has overflow and the other doesn't, check if the overflow vectors are all zero
200192
for (int i = 0; i < maxLen; i++)
201193
{
202194
var thisVec = i < thisLen ? _overflow[i] : Vector128<long>.Zero;
203195
var otherVec = i < otherLen ? other._overflow[i] : Vector128<long>.Zero;
204196

205197
if (!SimdOps.AreEqual(thisVec, otherVec))
206-
{
207-
Console.WriteLine($"Tag.Equals: overflow mismatch at index {i}");
208198
return false;
209-
}
210199
}
211200

212-
Console.WriteLine($"Tag.Equals: returning true");
213201
return true;
214202
}
215203

EasyEcs.Core/Context.Archetypes.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,9 @@ internal List<Archetype> GetMatchingArchetypes(in Tag queryTag)
4848
{
4949
lock (_structuralLock)
5050
{
51-
Console.WriteLine($"GetMatchingArchetypes: Searching for queryTag, Total archetypes: {Archetypes.Count}");
52-
5351
// Check cache
5452
if (_queryCache.TryGetValue(queryTag, out var cached))
55-
{
56-
Console.WriteLine($"GetMatchingArchetypes: Found in cache, {cached.Count} archetypes");
5753
return cached;
58-
}
5954

6055
// Build list of matching archetypes
6156
var matching = new List<Archetype>(16);
@@ -64,23 +59,14 @@ internal List<Archetype> GetMatchingArchetypes(in Tag queryTag)
6459
foreach (var kvp in Archetypes)
6560
{
6661
var archetype = kvp.Value;
67-
var result = (archetype.ComponentMask & queryTag);
68-
bool matches = result == queryTag;
69-
Console.WriteLine($"GetMatchingArchetypes: Archetype with {archetype.AliveCount} entities, matches={matches}");
70-
Console.WriteLine($" - archetype.ComponentMask: {archetype.ComponentMask}");
71-
Console.WriteLine($" - queryTag: {queryTag}");
72-
Console.WriteLine($" - result: {result}");
73-
7462
// SIMD-accelerated bitwise AND
7563
// An archetype matches if it contains all required components
76-
if (matches)
64+
if ((archetype.ComponentMask & queryTag) == queryTag)
7765
{
7866
matching.Add(archetype);
7967
}
8068
}
8169

82-
Console.WriteLine($"GetMatchingArchetypes: Found {matching.Count} matching archetypes (not from cache)");
83-
8470
// Cache for future queries
8571
_queryCache[queryTag] = matching;
8672
return matching;

EasyEcs.Core/Enumerators/GroupResultEnumerator.1.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ public GroupResultEnumerator(Context context)
3333
_entityIndexInArchetype = 0;
3434
Current = default;
3535

36-
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Starting query");
37-
3836
if (context.TagRegistry.TryGetTagBitIndex<T>(out var bitIdx))
3937
{
40-
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Found bitIdx = {bitIdx}");
41-
4238
// Safely access Components array (may not be initialized yet)
4339
if (context.Components != null && bitIdx < context.Components.Length)
4440
{
@@ -50,17 +46,8 @@ public GroupResultEnumerator(Context context)
5046

5147
// Get matching archetypes from cache (O(1) after first access)
5248
_matchingArchetypes = context.GetMatchingArchetypes(queryTag);
53-
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Found {_matchingArchetypes.Count} matching archetypes");
54-
}
55-
else
56-
{
57-
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: Components is null or bitIdx out of range. Components != null: {context.Components != null}, Components.Length: {context.Components?.Length ?? -1}, bitIdx: {bitIdx}");
5849
}
5950
}
60-
else
61-
{
62-
Console.WriteLine($"GroupResultEnumerator<{typeof(T).Name}>: TryGetTagBitIndex returned false");
63-
}
6451
}
6552

6653
public GroupResultEnumerator<T> GetEnumerator() => this;

EasyEcs.UnitTest/SimpleTest.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,14 @@ public async Task TrivialTest()
3030

3131
// Add components to the entity (immediate execution - no callbacks!)
3232
entity.AddComponent<SizeComponent>();
33-
var scaleCompRef = entity.AddComponent<ScaleComponent>(); // ResizeSystem will set factor to 2 in its OnInit
34-
35-
Console.WriteLine($"Before Init: Entity {entity.Id} has ScaleComponent: {entity.HasComponent<ScaleComponent>()}");
36-
Console.WriteLine($"Before Init: ScaleComponent.Factor = {scaleCompRef.Value.Factor}");
33+
entity.AddComponent<ScaleComponent>(); // ResizeSystem will set factor to 2 in its OnInit
3734

3835
// Start the context, automatically initializing all systems,
3936
// then when it is out of scope, it will dispose the context
4037
await using (await ctx.Init())
4138
{
4239
var entityById = ctx.GetEntityById(0);
4340

44-
Console.WriteLine($"After Init: Entity {entityById.Value.Id} has ScaleComponent: {entityById.Value.HasComponent<ScaleComponent>()}");
45-
Console.WriteLine($"After Init: ScaleComponent.Factor = {entityById.Value.GetComponent<ScaleComponent>().Value.Factor}");
46-
4741
// Check if factor is 2, implying ResizeSystem has set it in its OnInit
4842
Assert.That(entityById.Value.GetComponent<ScaleComponent>().Value.Factor, Is.EqualTo(2));
4943

EasyEcs.UnitTest/Systems/ResizeSystem.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,17 @@ public class ResizeSystem : SystemBase, IInitSystem, IExecuteSystem
1010
{
1111
public UniTask OnInit(Context context)
1212
{
13-
Console.WriteLine($"ResizeSystem.OnInit called");
14-
1513
// Get all entities that have ScaleComponent
1614
var candidates = context.GroupOf<ScaleComponent>();
1715

18-
int count = 0;
1916
// Iterate over all entities
2017
foreach (var result in candidates)
2118
{
22-
count++;
2319
ref var scaleComponent = ref result.Component1;
24-
Console.WriteLine($"ResizeSystem.OnInit: Found entity, current Factor = {scaleComponent.Factor}");
2520
// Set the factor to 2
2621
scaleComponent.Factor = 2;
27-
Console.WriteLine($"ResizeSystem.OnInit: Set Factor to {scaleComponent.Factor}");
2822
}
2923

30-
Console.WriteLine($"ResizeSystem.OnInit: Found {count} entities with ScaleComponent");
31-
3224
return UniTask.CompletedTask;
3325
}
3426

0 commit comments

Comments
 (0)