From 5884f262e77c9bdb4ff53822c24faaab1d69b762 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 12 Dec 2022 14:06:37 -0800 Subject: [PATCH] clear instead of realloc --- QSB/WorldSync/QSBWorldSync.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/QSB/WorldSync/QSBWorldSync.cs b/QSB/WorldSync/QSBWorldSync.cs index d6446f37..f0feb5e7 100644 --- a/QSB/WorldSync/QSBWorldSync.cs +++ b/QSB/WorldSync/QSBWorldSync.cs @@ -21,8 +21,9 @@ namespace QSB.WorldSync; public static class QSBWorldSync { public static WorldObjectManager[] Managers; - public static Dictionary ManagerHashes { get; private set; } = new(); - public static Dictionary> ManagerToBuiltObjects { get; private set; } = new(); + + private static readonly Dictionary> _managerToBuiltObjects = new(); + public static readonly Dictionary ManagerHashes = new(); /// /// Set when all WorldObjectManagers have called Init() on all their objects (AKA all the objects are created) @@ -87,7 +88,7 @@ public static class QSBWorldSync DeterministicManager.OnWorldObjectsAdded(); - foreach (var item in ManagerToBuiltObjects) + foreach (var item in _managerToBuiltObjects) { var worldObjects = item.Value; var hash = worldObjects.Select(x => x.GetType().Name).GetMD5Hash(); @@ -145,8 +146,8 @@ public static class QSBWorldSync AllObjectsAdded = false; AllObjectsReady = false; - ManagerToBuiltObjects = new(); - ManagerHashes = new(); + _managerToBuiltObjects.Clear(); + ManagerHashes.Clear(); GameReset(); @@ -440,14 +441,13 @@ public static class QSBWorldSync } var className = NameOfCallingClass(); - - if (!ManagerToBuiltObjects.ContainsKey(className)) + if (!_managerToBuiltObjects.ContainsKey(className)) { - ManagerToBuiltObjects.Add(className, new List { worldObject }); + _managerToBuiltObjects.Add(className, new List { worldObject }); } else { - ManagerToBuiltObjects[className].Add(worldObject); + _managerToBuiltObjects[className].Add(worldObject); } WorldObjects.Add(worldObject);