From 859ba303fce5942028d4ef2d8a028c335dd4f7cc Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Thu, 14 Apr 2022 17:10:32 +1000 Subject: [PATCH] Optimise decal allocs (#7550) I saw it at the time but didn't think it'd be as big of a deal as it is. --- Content.Client/Decals/DecalOverlay.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Content.Client/Decals/DecalOverlay.cs b/Content.Client/Decals/DecalOverlay.cs index 6cb43432dc..a5e5a2d831 100644 --- a/Content.Client/Decals/DecalOverlay.cs +++ b/Content.Client/Decals/DecalOverlay.cs @@ -19,6 +19,8 @@ namespace Content.Client.Decals public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities; + private readonly Dictionary _cachedTextures = new(64); + public DecalOverlay( DecalSystem decals, SharedTransformSystem transforms, @@ -37,10 +39,8 @@ namespace Content.Client.Decals protected override void Draw(in OverlayDrawArgs args) { + // Shouldn't need to clear cached textures unless the prototypes get reloaded. var handle = args.WorldHandle; - - Dictionary cachedTextures = new(); - var xformQuery = _entManager.GetEntityQuery(); foreach (var (gridId, zIndexDictionary) in _decals.DecalRenderIndex) @@ -54,11 +54,11 @@ namespace Content.Client.Decals { foreach (var (_, decal) in decals) { - if (!cachedTextures.TryGetValue(decal.Id, out var texture)) + if (!_cachedTextures.TryGetValue(decal.Id, out var texture)) { var sprite = GetDecalSprite(decal.Id); texture = _sprites.Frame0(sprite); - cachedTextures[decal.Id] = texture; + _cachedTextures[decal.Id] = texture; } if (decal.Angle.Equals(Angle.Zero))