Skip to content

Commit ef8720a

Browse files
author
Stefán J. Sigurðarson
committed
Adding a faster check for GetUTF8ByteCount for netcoreapp3.1
1 parent 0c2cfbb commit ef8720a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

projects/RabbitMQ.Client/client/impl/WireFormatting.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,11 @@ public static int GetFieldValueByteCount(object value)
498498
}
499499

500500
[MethodImpl(MethodImplOptions.AggressiveInlining)]
501+
#if NETCOREAPP
502+
public static int GetUTF8ByteCount(ReadOnlySpan<char> val) => val.IsEmpty ? 0 : Encoding.UTF8.GetByteCount(val);
503+
#else
501504
public static int GetUTF8ByteCount(string val) => string.IsNullOrEmpty(val) ? 0 : Encoding.UTF8.GetByteCount(val);
505+
#endif
502506

503507
[MethodImpl(MethodImplOptions.AggressiveInlining)]
504508
public static int WriteLong(Span<byte> span, uint val)

0 commit comments

Comments
 (0)