Skip to content

Commit

Permalink
FULL_RELEASE
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Sep 27, 2024
1 parent 97340df commit 3c4379e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Robust.Shared.CompNetworkGenerator/ComponentNetworkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3c4379e

Please sign in to comment.