Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Dec 4, 2024
1 parent 252fcd2 commit 603e1cf
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/DotNext.IO/Buffers/Binary/SevenBitEncodedInt32Reader.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace DotNext.Buffers.Binary;

[StructLayout(LayoutKind.Auto)]
internal struct SevenBitEncodedInt32Reader : IBufferReader, ISupplier<int>
{
private SevenBitEncodedInteger<uint> value;
private SevenBitEncodedInteger<uint> decoder;
private bool completed;

readonly int IBufferReader.RemainingBytes => Unsafe.BitCast<bool, byte>(!completed);

void IReadOnlySpanConsumer<byte>.Invoke(ReadOnlySpan<byte> source)
=> completed = value.Append(MemoryMarshal.GetReference(source)) is false;
=> completed = decoder.Append(MemoryMarshal.GetReference(source)) is false;

readonly int ISupplier<int>.Invoke() => (int)value.Value;
readonly int ISupplier<int>.Invoke() => (int)decoder.Value;
}

0 comments on commit 603e1cf

Please sign in to comment.