From 3c4379e300defe2862236f286e9aadab71853796 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Fri, 27 Sep 2024 17:58:42 +1000 Subject: [PATCH] FULL_RELEASE --- .../ComponentNetworkGenerator.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs b/Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs index 099ef1943d4..f6566575ca7 100644 --- a/Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs +++ b/Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs @@ -244,20 +244,29 @@ public class ComponentNetworkGenerator : ISourceGenerator stateFields.Append($@" public {typeDisplayStr} {name} = default!;"); + // get first ctor arg of the field attribute, which determines whether the field should be cloned + // (like if its a dict or list) if (IsCloneType(type)) { + // Avoid the allocations on release + #if !FULL_RELEASE if (type.NullableAnnotation == NullableAnnotation.NotAnnotated) { - // get first ctor arg of the field attribute, which determines whether the field should be cloned - // (like if its a dict or list) getStateInit.Append($@" - {name} = new(component.{name}),"); + {name} = new(component.{name}),"); } else { getStateInit.Append($@" - {name} = component.{name} == null ? null : new(component.{name}),"); + {name} = component.{name} == null ? null : new(component.{name}),"); } + #else + { + getStateInit.Append($@" + {name} = component.{name},"); + } + #endif + handleStateSetters.Append($@" if (state.{name} == null)