From a2920d07ddfca7f076e91b03261f464b2be85da0 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 9 Jul 2020 02:51:17 +0200 Subject: [PATCH] Optimize ContainerSlot --- Content.Server/GameObjects/ContainerSlot.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/ContainerSlot.cs b/Content.Server/GameObjects/ContainerSlot.cs index f38b907e3b..36dd215b5d 100644 --- a/Content.Server/GameObjects/ContainerSlot.cs +++ b/Content.Server/GameObjects/ContainerSlot.cs @@ -10,7 +10,18 @@ namespace Content.Server.GameObjects public class ContainerSlot : BaseContainer { [ViewVariables] - public IEntity ContainedEntity { get; private set; } = null; + public IEntity ContainedEntity + { + get => _containedEntity; + private set + { + _containedEntity = value; + _containedArray[0] = value; + } + } + + private readonly IEntity[] _containedArray = new IEntity[1]; + private IEntity _containedEntity; /// public override IReadOnlyCollection ContainedEntities @@ -22,7 +33,7 @@ namespace Content.Server.GameObjects return Array.Empty(); } - return new List {ContainedEntity}.AsReadOnly(); + return _containedArray; } }