Remove .ToArray() allocations from StepTriggerSystem Update (#8658)
This commit is contained in:
parent
cb4d5f3e59
commit
bdb6f7df1f
1 changed files with 17 additions and 5 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using System.Linq;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
|
|
@ -34,15 +34,27 @@ public sealed class StepTriggerSystem : EntitySystem
|
|||
component.Colliding.Count == 0)
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue