From 7fe8888df5a74667914c66c336625309279ff28a Mon Sep 17 00:00:00 2001 From: vis2k Date: Wed, 30 Oct 2019 20:18:02 +0100 Subject: [PATCH] perf: MultiplexTransport: avoid Linq allocations that would happen on every packet send because Send calls .ServerActive() each time --- Assets/Mirror/Runtime/Transport/MultiplexTransport.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Runtime/Transport/MultiplexTransport.cs b/Assets/Mirror/Runtime/Transport/MultiplexTransport.cs index e0a3cf17d..03cbad785 100644 --- a/Assets/Mirror/Runtime/Transport/MultiplexTransport.cs +++ b/Assets/Mirror/Runtime/Transport/MultiplexTransport.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using UnityEngine; @@ -138,7 +137,15 @@ void InitServer() public override bool ServerActive() { - return transports.All(t => t.ServerActive()); + // avoid Linq.All allocations + foreach (Transport transport in transports) + { + if (!transport.ServerActive()) + { + return false; + } + } + return true; } public override string ServerGetClientAddress(int connectionId)