CurtHagenlocher commented on PR #73:
URL: https://github.com/apache/arrow-dotnet/pull/73#issuecomment-3299358379
I think we can do better when targeting modern .NET. Consider instead
defining a helper like
```
#if NET5_0_OR_GREATER
struct IntBuffer
{
public void WriteLittleEndian(Stream stream, int value)
{
Span<byte> buffer = stackalloc byte[4];
BinaryPrimitives.WriteInt32LittleEndian(buffer, value);
stream.Write(buffer);
}
public void WriteLittleEndian(Stream stream, long value)
{
Span<byte> buffer = stackalloc byte[8];
BinaryPrimitives.WriteInt64LittleEndian(buffer, value);
stream.Write(buffer);
}
}
#else
struct IntBuffer
{
byte[] buffer;
public IntBuffer()
{
buffer = new byte[8];
}
public void WriteLittleEndian(Stream stream, int value)
{
BinaryPrimitives.WriteInt32LittleEndian(buffer, value);
stream.Write(buffer, 0, 4);
}
public void WriteLittleEndian(Stream stream, long value)
{
BinaryPrimitives.WriteInt64LittleEndian(buffer, value);
stream.Write(buffer, 0, 8);
}
}
#endif
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]