fix: Replaces throttlers and packet callbacks with function pointers (#1063)
Replaces multi-cast delegates with function pointers to gain 25% in performance and lower allocations.
This commit is contained in:
parent
b779d7737f
commit
f24b98f8e2
31 changed files with 189 additions and 172 deletions
|
|
@ -24,7 +24,8 @@ public static class IncomingPackets
|
|||
public static PacketHandler[] Handlers { get; } = new PacketHandler[0x100];
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Register(int packetID, int length, bool ingame, OnPacketReceive onReceive) =>
|
||||
public static unsafe void Register(int packetID, int length, bool ingame,
|
||||
delegate*<NetState, CircularBufferReader, int, void> onReceive) =>
|
||||
Register(new PacketHandler(packetID, length, ingame, onReceive));
|
||||
|
||||
public static void Register(PacketHandler packetHandler)
|
||||
|
|
@ -53,7 +54,7 @@ public static class IncomingPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void RegisterThrottler(int packetID, ThrottlePacketCallback t)
|
||||
public static unsafe void RegisterThrottler(int packetID, delegate*<int, NetState, out bool, bool> t)
|
||||
{
|
||||
var ph = GetHandler(packetID);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue