Skip to content

Commit

Permalink
perf: avoid boxing if there is no profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Sep 21, 2019
1 parent 4a13773 commit a351879
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Assets/Mirror/Runtime/NetworkDiagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal MessageInfo(IMessageBase message, int channel, int bytes, int count)
[Conditional("ENABLE_PROFILER")]
internal static void OnSend<T>(T message, int channel, int bytes, int count) where T : IMessageBase
{
if (count > 0)
if (count > 0 && OutMessageEvent != null)
{
MessageInfo outMessage = new MessageInfo(message, channel, bytes, count);
OutMessageEvent?.Invoke(outMessage);
Expand All @@ -74,8 +74,11 @@ internal MessageInfo(IMessageBase message, int channel, int bytes, int count)
[Conditional("ENABLE_PROFILER")]
internal static void OnReceive<T>(T message, int channel, int bytes) where T : IMessageBase
{
MessageInfo inMessage = new MessageInfo(message, channel, bytes, 1);
InMessageEvent?.Invoke(inMessage);
if (InMessageEvent != null)
{
MessageInfo inMessage = new MessageInfo(message, channel, bytes, 1);
InMessageEvent?.Invoke(inMessage);
}
}

#endregion
Expand Down

0 comments on commit a351879

Please sign in to comment.