Skip to content

Commit 671e313

Browse files
committed
perf: Fixed UnnamedMessage send scaling from O(n) to O(1) for n clients
1 parent 967cbbf commit 671e313

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

MLAPI/Messaging/CustomMessageManager.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,7 @@ public static void SendUnnamedMessage(List<ulong> clientIds, BitStream stream, s
5555
return;
5656
}
5757

58-
if (clientIds == null)
59-
{
60-
for (int i = 0; i < NetworkingManager.Singleton.ConnectedClientsList.Count; i++)
61-
{
62-
InternalMessageSender.Send(NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, MLAPIConstants.MLAPI_UNNAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, stream, security, null);
63-
}
64-
}
65-
else
66-
{
67-
for (int i = 0; i < clientIds.Count; i++)
68-
{
69-
InternalMessageSender.Send(clientIds[i], MLAPIConstants.MLAPI_UNNAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, stream, security, null);
70-
}
71-
}
58+
InternalMessageSender.Send(MLAPIConstants.MLAPI_UNNAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, clientIds, stream, security, null);
7259
}
7360

7461
/// <summary>

0 commit comments

Comments
 (0)