Remove .ToArray() allocations from StepTriggerSystem Update (#8658)
This commit is contained in:
committed by
GitHub
parent
cb4d5f3e59
commit
bdb6f7df1f
@@ -1,4 +1,4 @@
|
|||||||
using System.Linq;
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Physics.Dynamics;
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
@@ -34,15 +34,27 @@ public sealed class StepTriggerSystem : EntitySystem
|
|||||||
component.Colliding.Count == 0)
|
component.Colliding.Count == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
foreach (var otherUid in component.Colliding.ToArray())
|
var remQueue = new ValueList<EntityUid>();
|
||||||
|
foreach (var otherUid in component.Colliding)
|
||||||
{
|
{
|
||||||
var shouldRemoveFromColliding = UpdateColliding(component, transform, otherUid, query);
|
var shouldRemoveFromColliding = UpdateColliding(component, transform, otherUid, query);
|
||||||
if (!shouldRemoveFromColliding) continue;
|
if (!shouldRemoveFromColliding)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
remQueue.Add(otherUid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (remQueue.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var uid in remQueue)
|
||||||
|
{
|
||||||
|
component.Colliding.Remove(uid);
|
||||||
|
component.CurrentlySteppedOn.Remove(uid);
|
||||||
|
}
|
||||||
|
|
||||||
component.Colliding.Remove(otherUid);
|
|
||||||
component.CurrentlySteppedOn.Remove(otherUid);
|
|
||||||
Dirty(component);
|
Dirty(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user