perf: inline property calls in hot path

This commit is contained in:
mischa 2024-03-11 18:59:51 +08:00
parent 7bcaeb6f3a
commit 041953d6fe
2 changed files with 11 additions and 3 deletions

View File

@ -118,7 +118,7 @@ public bool authority
// component index from in here by searching all NetworkComponents.
/// <summary>Returns the NetworkIdentity of this object</summary>
public NetworkIdentity netIdentity { get; internal set; }
public NetworkIdentity netIdentity; // set from NetworkIdentity.InitializeNetworkBehaviours to avoid netIdentity=>flag indirection!
/// <summary>Returns the index of the component on this object</summary>
public byte ComponentIndex { get; internal set; }

View File

@ -238,12 +238,21 @@ internal set
/// <summary>Client's network connection to the server. This is only valid for player objects on the client.</summary>
// TODO change to NetworkConnectionToServer, but might cause some breaking
public NetworkConnection connectionToServer { get; internal set; }
public NetworkConnection connectionToServer
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal set;
}
/// <summary>Server's network connection to the client. This is only valid for client-owned objects (including the Player object) on the server.</summary>
NetworkConnectionToClient _connectionToClient;
public NetworkConnectionToClient connectionToClient
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => _connectionToClient;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal set
{
_connectionToClient?.RemoveOwnedObject(this);
@ -251,7 +260,6 @@ internal set
_connectionToClient?.AddOwnedObject(this);
}
}
NetworkConnectionToClient _connectionToClient;
// get all NetworkBehaviour components
public NetworkBehaviour[] NetworkBehaviours { get; private set; }