mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
perf(NetworkTransform): removing allocations from Command (#2491)
`byte[] payload` will cause a new array to be created when parameters are read, using `ArraySegment<byte>` avoids this.
This commit is contained in:
parent
53694e3be3
commit
99f7e9112d
@ -16,6 +16,7 @@
|
||||
// * Only way for smooth movement is to use a fixed movement speed during
|
||||
// interpolation. interpolation over time is never that good.
|
||||
//
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror
|
||||
@ -195,7 +196,7 @@ public override void OnDeserialize(NetworkReader reader, bool initialState)
|
||||
|
||||
// local authority client sends sync message to server for broadcasting
|
||||
[Command]
|
||||
void CmdClientToServerSync(byte[] payload)
|
||||
void CmdClientToServerSync(ArraySegment<byte> payload)
|
||||
{
|
||||
// Ignore messages from client if not in client authority mode
|
||||
if (!clientAuthority)
|
||||
@ -346,7 +347,7 @@ void Update()
|
||||
SerializeIntoWriter(writer, targetComponent.transform.localPosition, targetComponent.transform.localRotation, targetComponent.transform.localScale);
|
||||
|
||||
// send to server
|
||||
CmdClientToServerSync(writer.ToArray());
|
||||
CmdClientToServerSync(writer.ToArraySegment());
|
||||
}
|
||||
}
|
||||
lastClientSendTime = Time.time;
|
||||
|
Loading…
Reference in New Issue
Block a user