Skip to content

Commit d9f4e01

Browse files
committed
BitHelper needs local Span due to regression in jit-diff otherwise
1 parent 7e816a5 commit d9f4e01

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • src/libraries/Common/src/System/Collections/Generic

src/libraries/Common/src/System/Collections/Generic/BitHelper.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ internal BitHelper(Span<int> span, bool clear)
2020
internal void MarkBit(int bitPosition)
2121
{
2222
uint bitArrayIndex = (uint)bitPosition / IntSize;
23-
if (bitArrayIndex < (uint)_span.Length)
23+
Span<int> span = _span;
24+
if (bitArrayIndex < (uint)span.Length)
2425
{
25-
_span[(int)bitArrayIndex] |= (1 << (int)((uint)bitPosition % IntSize));
26+
span[(int)bitArrayIndex] |= (1 << (int)((uint)bitPosition % IntSize));
2627
}
2728
}
2829

2930
internal bool IsMarked(int bitPosition)
3031
{
3132
uint bitArrayIndex = (uint)bitPosition / IntSize;
33+
Span<int> span = _span;
3234
return
33-
bitArrayIndex < (uint)_span.Length &&
34-
(_span[(int)bitArrayIndex] & ((int)((uint)bitPosition % IntSize))) != 0;
35+
bitArrayIndex < (uint)span.Length &&
36+
(span[(int)bitArrayIndex] & ((int)((uint)bitPosition % IntSize))) != 0;
3537
}
3638

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

0 commit comments

Comments
 (0)