From 067397c71353c5abf0aa678ff803d62a12781146 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 11 Jan 2021 11:10:05 +0100 Subject: [PATCH] Cache Enum.GetValues(typeof(Priority)) in PowerNetNodeGroup --- .../Components/NodeContainer/NodeGroups/PowerNetNodeGroup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/PowerNetNodeGroup.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/PowerNetNodeGroup.cs index 6e6486b79e..59ff48ef1b 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/PowerNetNodeGroup.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeGroups/PowerNetNodeGroup.cs @@ -29,6 +29,8 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups [NodeGroup(NodeGroupID.HVPower, NodeGroupID.MVPower)] public class PowerNetNodeGroup : BaseNetConnectorNodeGroup, IPowerNet { + private static readonly Priority[] CachedPriorities = (Priority[]) Enum.GetValues(typeof(Priority)); + [Dependency] private readonly IPowerNetManager _powerNetManager = default!; [ViewVariables] @@ -121,7 +123,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.NodeGroups public void UpdateConsumerReceivedPower() { var remainingSupply = _totalSupply; - foreach (Priority priority in Enum.GetValues(typeof(Priority))) + foreach (var priority in CachedPriorities) { var categoryPowerDemand = _drawByPriority[priority]; if (remainingSupply >= categoryPowerDemand) //can fully power all in category