Skip to content

Commit

Permalink
Collapse .AsSpan().Slice(...) calls into .AsSpan(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewnoakes committed Feb 18, 2024
1 parent 4505428 commit cddd240
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MetadataExtractor/Formats/Gif/GifReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ private static byte[] GatherBytes(SequentialReader reader, byte firstLength)

while (length > 0)
{
reader.GetBytes(buffer.AsSpan().Slice(0, length));
reader.GetBytes(buffer.AsSpan(0, length));

stream.Write(buffer, 0, length);

Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/BufferReader.Indexed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public readonly string GetString(int index, int bytesRequested, Encoding encodin
{
byte[] bytes = ArrayPool<byte>.Shared.Rent(bytesRequested);

Span<byte> span = bytes.AsSpan().Slice(0, bytesRequested);
Span<byte> span = bytes.AsSpan(0, bytesRequested);

GetBytes(index, span);

Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/ByteArrayReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void GetBytes(int index, Span<byte> bytes)
{
ValidateIndex(index, bytes.Length);

_buffer.AsSpan().Slice(index + _baseOffset, bytes.Length).CopyTo(bytes);
_buffer.AsSpan(index + _baseOffset, bytes.Length).CopyTo(bytes);
}

protected override void ValidateIndex(int index, int bytesRequested)
Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/IndexedCapturingReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public override void GetBytes(int index, Span<byte> bytes)
GetPosition(fromIndex, out int fromChunkIndex, out int fromInnerIndex);
var length = Math.Min(remaining, _chunkLength - fromInnerIndex);
var chunk = _chunks[fromChunkIndex];
chunk.AsSpan().Slice(fromInnerIndex, length).CopyTo(bytes.Slice(toIndex, length));
chunk.AsSpan(fromInnerIndex, length).CopyTo(bytes.Slice(toIndex, length));
remaining -= length;
fromIndex += length;
toIndex += length;
Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/IndexedReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public string GetString(int index, int bytesRequested, Encoding encoding)
{
byte[] bytes = ArrayPool<byte>.Shared.Rent(bytesRequested);

Span<byte> span = bytes.AsSpan().Slice(0, bytesRequested);
Span<byte> span = bytes.AsSpan(0, bytesRequested);

GetBytes(index, span);

Expand Down
2 changes: 1 addition & 1 deletion MetadataExtractor/IO/SequentialReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public string GetString(int bytesRequested, Encoding encoding)
{
byte[] bytes = ArrayPool<byte>.Shared.Rent(bytesRequested);

Span<byte> span = bytes.AsSpan().Slice(0, bytesRequested);
Span<byte> span = bytes.AsSpan(0, bytesRequested);

GetBytes(span);

Expand Down

0 comments on commit cddd240

Please sign in to comment.