Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

//$Authors = Jiri Cincura (jiri@cincura.net)

using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -36,12 +38,31 @@ public int Read(byte[] buffer, int offset, int count)
{
return _stream.Read(buffer, offset, count);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int Read(Span<byte> buffer, int offset, int count)
{
return _stream.Read(buffer[offset..(offset+count)]);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueTask<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{
return new ValueTask<int>(_stream.ReadAsync(buffer, offset, count, cancellationToken));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueTask<int> ReadAsync(Memory<byte> buffer, int offset, int count, CancellationToken cancellationToken = default)
{
return _stream.ReadAsync(buffer.Slice(offset, count), cancellationToken);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(ReadOnlySpan<byte> buffer)
{
_stream.Write(buffer);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(byte[] buffer, int offset, int count)
{
Expand All @@ -53,6 +74,12 @@ public ValueTask WriteAsync(byte[] buffer, int offset, int count, CancellationTo
return new ValueTask(_stream.WriteAsync(buffer, offset, count, cancellationToken));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, int offset, int count, CancellationToken cancellationToken = default)
{
return _stream.WriteAsync(buffer.Slice(offset, count), cancellationToken);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Flush()
{
Expand Down
Loading