Optimise explosive depressurisation (#2190)

Slight increase. My whole life is staring at a profiler now.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-10-09 01:03:56 +11:00
committed by GitHub
parent 7dfb9a413c
commit b35fba18a1
2 changed files with 5 additions and 8 deletions

View File

@@ -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<IEntity> GetEntitiesInTileFast(this MapIndices indices, GridId gridId, GridTileLookupSystem? gridTileLookup = null)
{
var turf = indices.GetTileRef(gridId);
if (turf == null)
return Enumerable.Empty<IEntity>();
return GetEntitiesInTileFast(turf.Value, gridTileLookup);
gridTileLookup ??= EntitySystem.Get<GridTileLookupSystem>();
return gridTileLookup.GetEntitiesIntersecting(gridId, indices);
}
}
}

View File

@@ -29,12 +29,12 @@ namespace Content.Shared.Maps
/// <summary>
/// Attempts to get the turf at map indices with grid id or null if no such turf is found.
/// </summary>
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<IMapManager>();
mapManager ??= IoCManager.Resolve<IMapManager>();
if (!mapManager.TryGetGrid(gridId, out var grid))
return null;