Skip to content

Commit

Permalink
Update Number.NumberBuffer.cs (#102950)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamarb123 authored and pull[bot] committed Jun 12, 2024
1 parent 928bca3 commit 2909028
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/libraries/Common/src/System/Number.NumberBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ internal unsafe ref struct NumberBuffer
public bool IsNegative;
public bool HasNonZeroTail;
public NumberBufferKind Kind;
public byte* DigitsPtr;
public int DigitsLength;
public readonly Span<byte> Digits => new Span<byte>(DigitsPtr, DigitsLength);
public Span<byte> Digits;
public readonly byte* DigitsPtr => (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(Digits)); // safe since constructor expects Digits to refer to unmovable memory

public NumberBuffer(NumberBufferKind kind, byte* digits, int digitsLength) : this(kind, new Span<byte>(digits, digitsLength))
{
Expand All @@ -50,8 +49,7 @@ public NumberBuffer(NumberBufferKind kind, Span<byte> digits)
IsNegative = false;
HasNonZeroTail = false;
Kind = kind;
DigitsPtr = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(digits)); // Safe since memory must be fixed
DigitsLength = digits.Length;
Digits = digits;
#if DEBUG
Digits.Fill(0xCC);
#endif
Expand Down

0 comments on commit 2909028

Please sign in to comment.