Browse Source
Merge pull request #1815 from turbedi/AsSpan_Slice_parameters
Collapse AsSpan().Slice(..) calls into AsSpan(..)
pull/1820/head
Brian Popow
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
5 additions and
5 deletions
-
src/ImageSharp/Formats/Png/PngDecoderCore.cs
-
src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
-
src/ImageSharp/IO/ChunkedMemoryStream.cs
-
src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs
|
|
@ -1071,7 +1071,7 @@ namespace SixLabors.ImageSharp.Formats.Png |
|
|
int bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length); |
|
|
int bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length); |
|
|
while (bytesRead != 0) |
|
|
while (bytesRead != 0) |
|
|
{ |
|
|
{ |
|
|
uncompressedBytes.AddRange(this.buffer.AsSpan().Slice(0, bytesRead).ToArray()); |
|
|
uncompressedBytes.AddRange(this.buffer.AsSpan(0, bytesRead).ToArray()); |
|
|
bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length); |
|
|
bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -306,7 +306,7 @@ namespace SixLabors.ImageSharp.Formats.Webp |
|
|
|
|
|
|
|
|
// Check for VP8 magic bytes.
|
|
|
// Check for VP8 magic bytes.
|
|
|
this.currentStream.Read(this.buffer, 0, 3); |
|
|
this.currentStream.Read(this.buffer, 0, 3); |
|
|
if (!this.buffer.AsSpan().Slice(0, 3).SequenceEqual(WebpConstants.Vp8HeaderMagicBytes)) |
|
|
if (!this.buffer.AsSpan(0, 3).SequenceEqual(WebpConstants.Vp8HeaderMagicBytes)) |
|
|
{ |
|
|
{ |
|
|
WebpThrowHelper.ThrowImageFormatException("VP8 magic bytes not found"); |
|
|
WebpThrowHelper.ThrowImageFormatException("VP8 magic bytes not found"); |
|
|
} |
|
|
} |
|
|
|
|
|
@ -243,7 +243,7 @@ namespace SixLabors.ImageSharp.IO |
|
|
const string bufferMessage = "Offset subtracted from the buffer length is less than count."; |
|
|
const string bufferMessage = "Offset subtracted from the buffer length is less than count."; |
|
|
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage); |
|
|
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage); |
|
|
|
|
|
|
|
|
return this.ReadImpl(buffer.AsSpan().Slice(offset, count)); |
|
|
return this.ReadImpl(buffer.AsSpan(offset, count)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if SUPPORTS_SPAN_STREAM
|
|
|
#if SUPPORTS_SPAN_STREAM
|
|
|
@ -359,7 +359,7 @@ namespace SixLabors.ImageSharp.IO |
|
|
const string bufferMessage = "Offset subtracted from the buffer length is less than count."; |
|
|
const string bufferMessage = "Offset subtracted from the buffer length is less than count."; |
|
|
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage); |
|
|
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage); |
|
|
|
|
|
|
|
|
this.WriteImpl(buffer.AsSpan().Slice(offset, count)); |
|
|
this.WriteImpl(buffer.AsSpan(offset, count)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if SUPPORTS_SPAN_STREAM
|
|
|
#if SUPPORTS_SPAN_STREAM
|
|
|
|
|
|
@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms |
|
|
|
|
|
|
|
|
ResizeKernel kernel = this.CreateKernel(dataRowIndex, left, right); |
|
|
ResizeKernel kernel = this.CreateKernel(dataRowIndex, left, right); |
|
|
|
|
|
|
|
|
Span<double> kernelValues = this.tempValues.AsSpan().Slice(0, kernel.Length); |
|
|
Span<double> kernelValues = this.tempValues.AsSpan(0, kernel.Length); |
|
|
double sum = 0; |
|
|
double sum = 0; |
|
|
|
|
|
|
|
|
for (int j = left; j <= right; j++) |
|
|
for (int j = left; j <= right; j++) |
|
|
|