From 22e1bc32ccbaed62b1e8b4db9da3825dff16ebb8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 15 Oct 2026 04:57:13 +0200 Subject: [PATCH] RecordSeenDestroyed allocates nothing in the common path Sense runs for every pair of ships every tick: iterate Equipment by index and read the believed layout only for an item actually perceived destroyed. SenseAllocatesNothingOnceWarm failed on the previous commit (1257600 bytes). Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/Entity.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index ad645add4..e58abbac3 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -1060,12 +1060,12 @@ public abstract class Entity // record. The same PerceivesDestroyed Sense ends reveals by, applied to located mounts. private void RecordSeenDestroyed(Entity subject) { - _reveals.TryGetValue(subject, out var book); - var layout = LayoutOf(subject); - foreach (var item in subject.Equipment) + // Indexed, and the layout read only for an item actually perceived destroyed: Sense runs for every pair of ships every tick. + for (var i = 0; i < subject.Equipment.Count; i++) { + var item = subject.Equipment[i]; if (item.Hardpoint == null || !PerceivesDestroyed(subject, item)) continue; - if (!layout.Contains(item.Hardpoint) && (book == null || !book.ContainsKey(item))) continue; + if (!LayoutOf(subject).Contains(item.Hardpoint) && !(_reveals.TryGetValue(subject, out var book) && book.ContainsKey(item))) continue; if (!_seenDestroyed.TryGetValue(subject, out var seen)) _seenDestroyed[subject] = seen = new HashSet(); seen.Add(item.Hardpoint); }