Skip to content

Commit f2c3662

Browse files
committed
Replaced LINQ Dirty field counting code as it allocates garbage (?!?!)
1 parent 1d4cb9a commit f2c3662

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,13 @@ internal void SyncVarUpdate()
462462
SetDirtyness();
463463
if(Time.time - lastSyncTime >= SyncVarSyncDelay)
464464
{
465-
byte dirtyCount = (byte)dirtyFields.Count(x => x == true);
465+
byte dirtyCount = 0;
466+
for (byte i = 0; i < dirtyFields.Length; i++)
467+
{
468+
if (dirtyFields[i])
469+
dirtyCount++;
470+
}
471+
466472
if (dirtyCount == 0)
467473
return; //All up to date!
468474
//It's sync time!

0 commit comments

Comments
 (0)