Skip to content

Commit

Permalink
add NetDataWriter.AsReadOnlySpan()
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Jul 6, 2024
1 parent 637d262 commit e99f35f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LiteNetLib/Utils/NetDataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public int Length
get => _position;
}

#if LITENETLIB_SPANS || NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1 || NETCOREAPP3_1 || NET5_0 || NETSTANDARD2_1
public ReadOnlySpan<byte> AsReadOnlySpan()
{
return new ReadOnlySpan<byte>(_data, 0, _position);
}
#endif

public static readonly ThreadLocal<UTF8Encoding> uTF8Encoding = new ThreadLocal<UTF8Encoding>(() => new UTF8Encoding(false, true));

public NetDataWriter() : this(true, InitialSize)
Expand Down

0 comments on commit e99f35f

Please sign in to comment.