Skip to content

Commit 3fdeeb0

Browse files
authored
Merge pull request #410 from drewnoakes/use-spans-in-dotnet-8
Use spans in readers in .NET 8
2 parents 4505428 + 990e635 commit 3fdeeb0

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

MetadataExtractor/IO/IndexedSeekingReader.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public IndexedSeekingReader(Stream stream, int baseOffset = 0, bool isMotorolaBy
4141

4242
public override long Length { get; }
4343

44-
#if !NETSTANDARD2_1
44+
#if !NETSTANDARD2_1 && !NET8_0_OR_GREATER
4545
private readonly byte[] _buffer = new byte[2048];
4646
#endif
4747

@@ -59,7 +59,7 @@ public override void GetBytes(int index, Span<byte> bytes)
5959
while (totalBytesRead != bytes.Length)
6060
{
6161
var target = bytes.Slice(totalBytesRead);
62-
#if NETSTANDARD2_1
62+
#if NETSTANDARD2_1 || NET8_0_OR_GREATER
6363
var bytesRead = _stream.Read(target);
6464
#else
6565
var len = Math.Min(bytes.Length - totalBytesRead, _buffer.Length);
@@ -75,7 +75,6 @@ public override void GetBytes(int index, Span<byte> bytes)
7575

7676
Debug.Assert(totalBytesRead <= bytes.Length);
7777
}
78-
7978
}
8079

8180
private void Seek(int index)

MetadataExtractor/IO/SequentialStreamReader.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override void GetBytes(byte[] buffer, int offset, int count)
5151
}
5252
}
5353

54-
#if !NETSTANDARD2_1
54+
#if !NETSTANDARD2_1 && !NET8_0_OR_GREATER
5555
private readonly byte[] _buffer = new byte[2048];
5656
#endif
5757

@@ -62,7 +62,7 @@ public override void GetBytes(Span<byte> bytes)
6262
while (totalBytesRead != bytes.Length)
6363
{
6464
var target = bytes.Slice(totalBytesRead);
65-
#if NETSTANDARD2_1
65+
#if NETSTANDARD2_1 || NET8_0_OR_GREATER
6666
var bytesRead = _stream.Read(target);
6767
#else
6868
var len = Math.Min(bytes.Length - totalBytesRead, _buffer.Length);

0 commit comments

Comments
 (0)