From f2c3662f631300a1061d4be12ea87ba31eeab96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Tue, 3 Apr 2018 19:16:07 +0200 Subject: [PATCH] Replaced LINQ Dirty field counting code as it allocates garbage (?!?!) --- MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs index 18db5c8..4f06c87 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs @@ -462,7 +462,13 @@ namespace MLAPI.MonoBehaviours.Core SetDirtyness(); if(Time.time - lastSyncTime >= SyncVarSyncDelay) { - byte dirtyCount = (byte)dirtyFields.Count(x => x == true); + byte dirtyCount = 0; + for (byte i = 0; i < dirtyFields.Length; i++) + { + if (dirtyFields[i]) + dirtyCount++; + } + if (dirtyCount == 0) return; //All up to date! //It's sync time!