Skip to content

Commit c8f6d75

Browse files
authored
Merge pull request #1815 from turbedi/AsSpan_Slice_parameters
Collapse AsSpan().Slice(..) calls into AsSpan(..)
2 parents 6f0e825 + 10750fc commit c8f6d75

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ private bool TryUncompressTextData(ReadOnlySpan<byte> compressedData, Encoding e
10711071
int bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length);
10721072
while (bytesRead != 0)
10731073
{
1074-
uncompressedBytes.AddRange(this.buffer.AsSpan().Slice(0, bytesRead).ToArray());
1074+
uncompressedBytes.AddRange(this.buffer.AsSpan(0, bytesRead).ToArray());
10751075
bytesRead = inflateStream.CompressedStream.Read(this.buffer, 0, this.buffer.Length);
10761076
}
10771077

src/ImageSharp/Formats/Webp/WebpDecoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private WebpImageInfo ReadVp8Header(WebpFeatures features = null)
306306

307307
// Check for VP8 magic bytes.
308308
this.currentStream.Read(this.buffer, 0, 3);
309-
if (!this.buffer.AsSpan().Slice(0, 3).SequenceEqual(WebpConstants.Vp8HeaderMagicBytes))
309+
if (!this.buffer.AsSpan(0, 3).SequenceEqual(WebpConstants.Vp8HeaderMagicBytes))
310310
{
311311
WebpThrowHelper.ThrowImageFormatException("VP8 magic bytes not found");
312312
}

src/ImageSharp/IO/ChunkedMemoryStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public override int Read(byte[] buffer, int offset, int count)
243243
const string bufferMessage = "Offset subtracted from the buffer length is less than count.";
244244
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage);
245245

246-
return this.ReadImpl(buffer.AsSpan().Slice(offset, count));
246+
return this.ReadImpl(buffer.AsSpan(offset, count));
247247
}
248248

249249
#if SUPPORTS_SPAN_STREAM
@@ -359,7 +359,7 @@ public override void Write(byte[] buffer, int offset, int count)
359359
const string bufferMessage = "Offset subtracted from the buffer length is less than count.";
360360
Guard.IsFalse(buffer.Length - offset < count, nameof(buffer), bufferMessage);
361361

362-
this.WriteImpl(buffer.AsSpan().Slice(offset, count));
362+
this.WriteImpl(buffer.AsSpan(offset, count));
363363
}
364364

365365
#if SUPPORTS_SPAN_STREAM

src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeKernelMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private ResizeKernel BuildKernel<TResampler>(in TResampler sampler, int destRowI
216216

217217
ResizeKernel kernel = this.CreateKernel(dataRowIndex, left, right);
218218

219-
Span<double> kernelValues = this.tempValues.AsSpan().Slice(0, kernel.Length);
219+
Span<double> kernelValues = this.tempValues.AsSpan(0, kernel.Length);
220220
double sum = 0;
221221

222222
for (int j = left; j <= right; j++)

0 commit comments

Comments
 (0)