Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret committed Apr 19, 2024
1 parent 467afb9 commit 135a452
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/ArtemisNetCoreClient/ArtemisBinaryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ public static int WriteString(ref byte destination, string value)
var offset = WriteInt32(ref destination, length);
if (value.Length < 9)
{
offset += WriteAsShorts(ref destination.GetOffset(offset), value);
foreach (var c in value)
{
offset += WriteInt16(ref destination.GetOffset(offset), (short) c);
}
}
else if (value.Length < 0xFFF)
{
Expand Down Expand Up @@ -265,17 +268,6 @@ public static int WriteString(ref byte destination, string value)

return offset;
}

private static int WriteAsShorts(ref byte destination, string value)
{
var offset = 0;
foreach (var c in value)
{
offset += WriteInt16(ref destination.GetOffset(offset), (short) c);
}

return offset;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetNullableStringByteCount(string? value)
Expand Down

0 comments on commit 135a452

Please sign in to comment.