From 456fde07bc4c841304d8c5a0f4a963d7d16bd03d Mon Sep 17 00:00:00 2001 From: James Frowen Date: Thu, 2 Apr 2020 17:49:38 +0100 Subject: [PATCH] removing cahced field (#1641) --- Assets/Mirror/Runtime/NetworkIdentity.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 3b094b221..927287633 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -1233,10 +1233,6 @@ internal void Reset() ClearObservers(); } - // MirrorUpdate is a hot path. Caching the vars msg is really worth it to - // avoid large amounts of allocations. - static UpdateVarsMessage varsMessage = new UpdateVarsMessage(); - // invoked by NetworkServer during Update() internal void ServerUpdate() { @@ -1249,8 +1245,10 @@ internal void ServerUpdate() OnSerializeAllSafely(false, ownerWriter, out int ownerWritten, observersWriter, out int observersWritten); if (ownerWritten > 0 || observersWritten > 0) { - // populate cached UpdateVarsMessage and send - varsMessage.netId = netId; + UpdateVarsMessage varsMessage = new UpdateVarsMessage + { + netId = netId + }; // send ownerWriter to owner // (only if we serialized anything for owner)