Skip to content

Commit ad67976

Browse files
committed
simple input size
1 parent 26645ce commit ad67976

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/Backdash/Extensions.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using System.Runtime.CompilerServices;
21
using Backdash.Network;
32
using Backdash.Network.Protocol;
4-
using Backdash.Serialization;
53

64
namespace Backdash;
75

@@ -15,13 +13,6 @@ public static void EnqueueNext<T>(this Queue<T> queue, in T value)
1513
queue.Enqueue(queue.Dequeue());
1614
}
1715

18-
public static int GetTypeSize<T>(this IBinarySerializer<T> serializer) where T : struct
19-
{
20-
T dummy = new();
21-
Span<byte> buffer = stackalloc byte[Unsafe.SizeOf<T>()];
22-
return serializer.Serialize(in dummy, buffer);
23-
}
24-
2516
public static PlayerConnectionStatus ToPlayerStatus(this ProtocolStatus status) => status switch
2617
{
2718
ProtocolStatus.Syncing => PlayerConnectionStatus.Syncing,

src/Backdash/Network/Protocol/Comm/ProtocolInputBuffer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Runtime.CompilerServices;
12
using Backdash.Core;
23
using Backdash.Data;
34
using Backdash.Network.Messages;
@@ -57,7 +58,7 @@ public ProtocolInputBuffer(ProtocolOptions options,
5758
this.timeSync = timeSync;
5859
this.sender = sender;
5960
this.inbox = inbox;
60-
inputSize = inputSerializer.GetTypeSize();
61+
inputSize = Unsafe.SizeOf<TInput>();
6162
ThrowIf.Assert(inputSize * ByteSize.ByteToBits < 1 << ByteSize.ByteToBits);
6263
workingBufferMemory = Mem.AllocatePinnedArray(WorkingBufferFactor * inputSize);
6364
pendingOutput = new(options.MaxPendingInputs);

0 commit comments

Comments
 (0)