From 46d63a8a6dbe4f88637342461c22ca2c1a290ca1 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 6 Apr 2022 01:07:11 +1000 Subject: [PATCH] Reduce move allocs (#7437) --- Content.Shared/Inventory/InventorySystem.Slots.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Inventory/InventorySystem.Slots.cs b/Content.Shared/Inventory/InventorySystem.Slots.cs index 772e8da2ba..34242f3c58 100644 --- a/Content.Shared/Inventory/InventorySystem.Slots.cs +++ b/Content.Shared/Inventory/InventorySystem.Slots.cs @@ -48,8 +48,14 @@ public partial class InventorySystem : EntitySystem if (!_prototypeManager.TryIndex(inventory.TemplateId, out var templatePrototype)) return false; - slotDefinition = templatePrototype.Slots.FirstOrDefault(x => x.Name == slot); - return slotDefinition != default; + foreach (var slotDef in templatePrototype.Slots) + { + if (!slotDef.Name.Equals(slot)) continue; + slotDefinition = slotDef; + return true; + } + + return false; } public bool TryGetContainerSlotEnumerator(EntityUid uid, out ContainerSlotEnumerator containerSlotEnumerator, InventoryComponent? component = null)