From e48c5f90fdecbc0fc478b7386ea619dac40c85b6 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Mon, 13 Feb 2023 17:43:25 +0100 Subject: [PATCH] feat(packets): accept ReadOnlySpan instead of string in serializer --- Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs | 3 ++- Packets/NosSmooth.PacketSerializer/PacketSerializer.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs b/Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs index 118cac5076684ce2405b6443677a9359ce800c28..421ce0e4a0bd5141766419afb1d3a0d14fe53be0 100644 --- a/Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs +++ b/Packets/NosSmooth.PacketSerializer/IPacketSerializer.cs @@ -4,6 +4,7 @@ // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using NosSmooth.Packets; using NosSmooth.PacketSerializer.Abstractions.Attributes; using Remora.Results; @@ -28,5 +29,5 @@ public interface IPacketSerializer /// The packet string to deserialize. /// The preferred source to check first. If packet with the given header is not found there, other sources will be checked as well. /// The parsed object or an error. - public Result Deserialize(string packetString, PacketSource preferredSource); + public Result Deserialize(ReadOnlySpan packetString, PacketSource preferredSource); } \ No newline at end of file diff --git a/Packets/NosSmooth.PacketSerializer/PacketSerializer.cs b/Packets/NosSmooth.PacketSerializer/PacketSerializer.cs index 7e864d643d4debe28b6035956b52dc6981eaea66..7e6fd6567f452a6672930041b342b7d9ca4d3e9b 100644 --- a/Packets/NosSmooth.PacketSerializer/PacketSerializer.cs +++ b/Packets/NosSmooth.PacketSerializer/PacketSerializer.cs @@ -4,6 +4,7 @@ // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using NosSmooth.Packets; using NosSmooth.PacketSerializer.Abstractions; using NosSmooth.PacketSerializer.Abstractions.Attributes; @@ -57,7 +58,7 @@ public class PacketSerializer : IPacketSerializer } /// - public Result Deserialize(string packetString, PacketSource preferredSource) + public Result Deserialize(ReadOnlySpan packetString, PacketSource preferredSource) { var packetStringEnumerator = new PacketStringEnumerator(packetString); var headerTokenResult = packetStringEnumerator.GetNextToken(out var packetToken);