Skip to content

Commit

Permalink
perf: removing allocations for validating network identity in debug mode
Browse files Browse the repository at this point in the history
Simple if check to avoid allocations when #if debug is defined when spawning network identities
  • Loading branch information
James-Frowen committed Aug 7, 2022
1 parent 00ea2f2 commit 1909749
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Assets/Mirage/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ private NetworkBehaviour[] FindBehaviourForThisIdentity()
// we only need to do this in debug mode because results should be right
foreach (var item in components)
{
logger.Assert(item.Identity == this, $"Child NetworkBehaviour had a different Identity, this:{name}, Child Identity:{item.Identity.name}");
// assert
if (item.Identity != this)
{
logger.LogError($"Child NetworkBehaviour had a different Identity, this:{name}, Child Identity:{item.Identity.name}");
}
}
#endif
return components;
Expand Down

0 comments on commit 1909749

Please sign in to comment.