Skip to content

Commit 75dce33

Browse files
committed
perf: Fixed NamedMessage send scaling from O(n) to O(1) for n clients
1 parent 671e313 commit 75dce33

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

MLAPI/Messaging/CustomMessageManager.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,8 @@ public static void SendNamedMessage(string name, List<ulong> clientIds, Stream s
202202
if (NetworkLog.CurrentLogLevel <= LogLevel.Error) NetworkLog.LogWarning("Can not send named messages to multiple users as a client");
203203
return;
204204
}
205-
if (clientIds == null)
206-
{
207-
for (int i = 0; i < NetworkingManager.Singleton.ConnectedClientsList.Count; i++)
208-
{
209-
InternalMessageSender.Send(NetworkingManager.Singleton.ConnectedClientsList[i].ClientId, MLAPIConstants.MLAPI_NAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, messageStream, security, null);
210-
}
211-
}
212-
else
213-
{
214-
for (int i = 0; i < clientIds.Count; i++)
215-
{
216-
InternalMessageSender.Send(clientIds[i], MLAPIConstants.MLAPI_NAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, messageStream, security, null);
217-
}
218-
}
205+
206+
InternalMessageSender.Send(MLAPIConstants.MLAPI_NAMED_MESSAGE, string.IsNullOrEmpty(channel) ? "MLAPI_DEFAULT_MESSAGE" : channel, clientIds, messageStream, security, null);
219207
}
220208
}
221209
#endregion

0 commit comments

Comments
 (0)