Skip to content

Commit

Permalink
perf: MultiplexTransport: avoid Linq allocations that would happen on…
Browse files Browse the repository at this point in the history
… every packet send because Send calls .ServerActive() each time
  • Loading branch information
miwarnec committed Oct 30, 2019
1 parent 40f50ac commit 7fe8888
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Assets/Mirror/Runtime/Transport/MultiplexTransport.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7fe8888

Please sign in to comment.