perf: remove syncvar boxing (#927)

This commit is contained in:
Paul Pacheco 2019-06-23 10:02:30 -05:00 committed by GitHub
parent 9e911b9d5e
commit b2ba5896fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -423,8 +423,7 @@ protected NetworkIdentity GetSyncVarNetworkIdentity(uint netId, ref NetworkIdent
protected void SetSyncVar<T>(T value, ref T fieldValue, ulong dirtyBit) protected void SetSyncVar<T>(T value, ref T fieldValue, ulong dirtyBit)
{ {
// newly initialized or changed value? // newly initialized or changed value?
if ((value == null && fieldValue != null) || if (!EqualityComparer<T>.Default.Equals(value, fieldValue))
(value != null && !value.Equals(fieldValue)))
{ {
if (LogFilter.Debug) Debug.Log("SetSyncVar " + GetType().Name + " bit [" + dirtyBit + "] " + fieldValue + "->" + value); if (LogFilter.Debug) Debug.Log("SetSyncVar " + GetType().Name + " bit [" + dirtyBit + "] " + fieldValue + "->" + value);
SetDirtyBit(dirtyBit); SetDirtyBit(dirtyBit);