Skip to content

[C#] Use new decimal.GetBits overloads to reduce allocations when serializing decimal values #44237

@georgevanburgh

Description

@georgevanburgh

Describe the enhancement requested

Similar to #41349, .NET 5 introduced new overloads for decimalGetBits for which allow the use of a stackalloc'ed span, and avoiding the allocation of a fresh byte array for each value serialized. This should (slightly) reduce the allocations associated with serializing C# decimal values.

int[] decimalBits = decimal.GetBits(value);

Component(s)

C#

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions