ReactionPrototype now uses arrays instead of lists internally.

Just a tiny optimization.
This commit is contained in:
Pieter-Jan Briers
2021-01-23 19:36:48 +01:00
parent 1eb5af6449
commit 8b2f28f155

View File

@@ -1,4 +1,5 @@
#nullable enable #nullable enable
using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Interfaces.Chemistry; using Content.Server.Interfaces.Chemistry;
using Content.Shared.Interfaces; using Content.Shared.Interfaces;
@@ -20,7 +21,7 @@ namespace Content.Shared.Chemistry
private string _name = default!; private string _name = default!;
private Dictionary<string, ReactantPrototype> _reactants = default!; private Dictionary<string, ReactantPrototype> _reactants = default!;
private Dictionary<string, ReagentUnit> _products = default!; private Dictionary<string, ReagentUnit> _products = default!;
private List<IReactionEffect> _effects = default!; private IReactionEffect[] _effects = default!;
public string ID => _id; public string ID => _id;
public string Name => _name; public string Name => _name;
@@ -55,11 +56,11 @@ namespace Content.Shared.Chemistry
{ {
//TODO: Don't have a check for if this is the server //TODO: Don't have a check for if this is the server
//Some implementations of IReactionEffect can't currently be moved to shared, so this is here to prevent the client from breaking when reading server-only IReactionEffects. //Some implementations of IReactionEffect can't currently be moved to shared, so this is here to prevent the client from breaking when reading server-only IReactionEffects.
serializer.DataField(ref _effects, "effects", new List<IReactionEffect>()); serializer.DataField(ref _effects, "effects", Array.Empty<IReactionEffect>());
} }
else else
{ {
_effects = new(); //To ensure _effects isn't null since it is only serializable on the server right snow _effects = Array.Empty<IReactionEffect>(); //To ensure _effects isn't null since it is only serializable on the server right snow
} }
} }
} }