Reduce move allocs (#7437)

This commit is contained in:
metalgearsloth
2022-04-06 01:07:11 +10:00
committed by GitHub
parent dac87317ec
commit 46d63a8a6d

View File

@@ -48,8 +48,14 @@ public partial class InventorySystem : EntitySystem
if (!_prototypeManager.TryIndex<InventoryTemplatePrototype>(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)