Skip to content

Commit

Permalink
Slightly optimized how bytes are read.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Oct 23, 2024
1 parent 148a633 commit cecc11f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Schema/src/binary/reader/EndianBinaryBufferedStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public void FillBuffer(Span<byte> buffer, int? optStride = null) {
this.reverserImpl_.ReverseElements(buffer, stride);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte ReadByte() {
this.AssertNotEof();
return this.BaseStream.ReadByte();
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Read<T>() where T : unmanaged {
Expand Down
4 changes: 2 additions & 2 deletions Schema/src/binary/reader/SchemaBinaryReader_Numbers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void AssertByte(byte expectedValue)
byte IReadableStream.ReadByte() => this.ReadByte();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte ReadByte() => this.bufferedStream_.Read<byte>();
public byte ReadByte() => this.bufferedStream_.ReadByte();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte[] ReadBytes(long count) {
Expand All @@ -38,7 +38,7 @@ public void AssertSByte(sbyte expectedValue)
=> SchemaBinaryReader.Assert_(expectedValue, this.ReadSByte());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sbyte ReadSByte() => this.bufferedStream_.Read<sbyte>();
public sbyte ReadSByte() => (sbyte) this.ReadByte();

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sbyte[] ReadSBytes(long count) {
Expand Down

0 comments on commit cecc11f

Please sign in to comment.