From b35fba18a17f8a7972d12da21b8928547e08027d Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 9 Oct 2020 01:03:56 +1100 Subject: [PATCH] Optimise explosive depressurisation (#2190) Slight increase. My whole life is staring at a profiler now. Co-authored-by: Metal Gear Sloth --- Content.Server/Utility/GridTileLookupHelpers.cs | 9 +++------ Content.Shared/Maps/TurfHelpers.cs | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Content.Server/Utility/GridTileLookupHelpers.cs b/Content.Server/Utility/GridTileLookupHelpers.cs index 2494815d2f..971ff6d0c7 100644 --- a/Content.Server/Utility/GridTileLookupHelpers.cs +++ b/Content.Server/Utility/GridTileLookupHelpers.cs @@ -6,6 +6,7 @@ using Content.Shared.Maps; using Robust.Server.GameObjects.EntitySystems.TileLookup; using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Interfaces.Map; using Robust.Shared.Map; namespace Content.Server.Utility @@ -29,12 +30,8 @@ namespace Content.Server.Utility [MethodImpl(MethodImplOptions.AggressiveInlining)] public static IEnumerable GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem? gridTileLookup = null) { - var turf = indices.GetTileRef(gridId); - - if (turf == null) - return Enumerable.Empty(); - - return GetEntitiesInTileFast(turf.Value, gridTileLookup); + gridTileLookup ??= EntitySystem.Get(); + return gridTileLookup.GetEntitiesIntersecting(gridId, indices); } } } diff --git a/Content.Shared/Maps/TurfHelpers.cs b/Content.Shared/Maps/TurfHelpers.cs index 7207647375..c35bfce426 100644 --- a/Content.Shared/Maps/TurfHelpers.cs +++ b/Content.Shared/Maps/TurfHelpers.cs @@ -29,12 +29,12 @@ namespace Content.Shared.Maps /// /// Attempts to get the turf at map indices with grid id or null if no such turf is found. /// - public static TileRef? GetTileRef(this MapIndices mapIndices, GridId gridId) + public static TileRef? GetTileRef(this MapIndices mapIndices, GridId gridId, IMapManager mapManager = null) { if (!gridId.IsValid()) return null; - var mapManager = IoCManager.Resolve(); + mapManager ??= IoCManager.Resolve(); if (!mapManager.TryGetGrid(gridId, out var grid)) return null;