Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-44237: [C#] Use stack allocated buffer when serializing decimal values #44238

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions csharp/src/Apache.Arrow/DecimalUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ internal static void GetBytes(decimal value, int precision, int scale, int byteW
{
// create BigInteger from decimal
BigInteger bigInt;

#if NET5_0_OR_GREATER
Span<int> decimalBits = stackalloc int[4];
decimal.GetBits(value, decimalBits);
#else
int[] decimalBits = decimal.GetBits(value);
#endif

int decScale = (decimalBits[3] >> 16) & 0x7F;
#if NETCOREAPP
Span<byte> bigIntBytes = stackalloc byte[13];
Expand Down
Loading