Updates compression to work with the public span
This commit is contained in:
Родитель
8ad66664bb
Коммит
e20975b6bc
|
@ -558,14 +558,14 @@ namespace Compression
|
|||
return WriteAsyncMemory (new ReadOnlyMemory<byte> (array, offset, count), cancellationToken);
|
||||
}
|
||||
|
||||
public override Task WriteAsync (ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
|
||||
public override ValueTask WriteAsync (ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
|
||||
{
|
||||
if (GetType () != typeof (CompressionStream)) {
|
||||
// Ensure that existing streams derived from DeflateStream and that override WriteAsync(byte[],...)
|
||||
// get their existing behaviors when the newer Memory-based overload is used.
|
||||
return base.WriteAsync (source, cancellationToken);
|
||||
} else {
|
||||
return WriteAsyncMemory (source, cancellationToken);
|
||||
return new ValueTask(WriteAsyncMemory (source, cancellationToken));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,7 +576,7 @@ namespace Compression
|
|||
EnsureNotDisposed ();
|
||||
|
||||
return cancellationToken.IsCancellationRequested ?
|
||||
Task.FromCanceled<int> (cancellationToken) :
|
||||
Task.FromCanceled<int>(cancellationToken) :
|
||||
WriteAsyncMemoryCore (source, cancellationToken);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Compression
|
|||
{
|
||||
if (!NeedsInput ())
|
||||
throw new InvalidOperationException ("We have something left in previous input!");
|
||||
if (_inputBufferHandle.HasPointer)
|
||||
if (_inputBufferHandle.Pointer == null)
|
||||
throw new InvalidOperationException ("Unexpected input buffer handler found.");
|
||||
|
||||
if (0 == inputBuffer.Length) {
|
||||
|
@ -71,7 +71,7 @@ namespace Compression
|
|||
}
|
||||
|
||||
lock (SyncLock) {
|
||||
_inputBufferHandle = inputBuffer.Retain (pin: true);
|
||||
_inputBufferHandle = inputBuffer.Pin ();
|
||||
|
||||
_compression_struct.Source = (IntPtr)_inputBufferHandle.Pointer;
|
||||
_compression_struct.SourceSize = inputBuffer.Length;
|
||||
|
@ -84,7 +84,7 @@ namespace Compression
|
|||
throw new InvalidOperationException ("We have something left in previous input!");
|
||||
if (inputBufferPtr == null)
|
||||
throw new ArgumentNullException ( nameof (inputBufferPtr));
|
||||
if (_inputBufferHandle.HasPointer)
|
||||
if (_inputBufferHandle.Pointer == null)
|
||||
throw new InvalidOperationException ("Unexpected input buffer handler found.");
|
||||
|
||||
if (count == 0) {
|
||||
|
@ -155,7 +155,7 @@ namespace Compression
|
|||
/// <summary>
|
||||
/// Returns true if there was something to flush. Otherwise False.
|
||||
/// </summary>
|
||||
internal bool Flush (byte[] outputBuffer, out int bytesRead)
|
||||
internal unsafe bool Flush (byte[] outputBuffer, out int bytesRead)
|
||||
{
|
||||
if (outputBuffer == null)
|
||||
throw new ArgumentNullException (nameof (outputBuffer));
|
||||
|
@ -163,7 +163,7 @@ namespace Compression
|
|||
throw new ArgumentException ("Can't pass in an empty output buffer!");
|
||||
if (!NeedsInput ())
|
||||
throw new InvalidOperationException ("We have something left in previous input!");
|
||||
if (_inputBufferHandle.HasPointer)
|
||||
if (_inputBufferHandle.Pointer == null)
|
||||
throw new InvalidOperationException ("InputHandler should not be set");
|
||||
|
||||
// Note: we require that NeedsInput() == true, i.e. that 0 == _zlibStream.AvailIn.
|
||||
|
|
Загрузка…
Ссылка в новой задаче