Skip to content

Commit

Permalink
BitHelper needs local Span due to regression in jit-diff otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
gfoidl committed Apr 4, 2022
1 parent 7e816a5 commit d9f4e01
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libraries/Common/src/System/Collections/Generic/BitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ internal BitHelper(Span<int> span, bool clear)
internal void MarkBit(int bitPosition)
{
uint bitArrayIndex = (uint)bitPosition / IntSize;
if (bitArrayIndex < (uint)_span.Length)
Span<int> span = _span;
if (bitArrayIndex < (uint)span.Length)
{
_span[(int)bitArrayIndex] |= (1 << (int)((uint)bitPosition % IntSize));
span[(int)bitArrayIndex] |= (1 << (int)((uint)bitPosition % IntSize));
}
}

internal bool IsMarked(int bitPosition)
{
uint bitArrayIndex = (uint)bitPosition / IntSize;
Span<int> span = _span;
return
bitArrayIndex < (uint)_span.Length &&
(_span[(int)bitArrayIndex] & ((int)((uint)bitPosition % IntSize))) != 0;
bitArrayIndex < (uint)span.Length &&
(span[(int)bitArrayIndex] & ((int)((uint)bitPosition % IntSize))) != 0;
}

/// <summary>How many ints must be allocated to represent n bits. Returns (n+31)/32, but avoids overflow.</summary>
Expand Down

0 comments on commit d9f4e01

Please sign in to comment.