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

Fix regression in Number.NumberBuffer.cs #102950

Merged
merged 1 commit into from
Jun 1, 2024
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
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
Loading