From d9f4e01930f78f1c42c29514ea18fe05dee248f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Mon, 4 Apr 2022 19:50:47 +0200 Subject: [PATCH] BitHelper needs local Span due to regression in jit-diff otherwise --- .../Common/src/System/Collections/Generic/BitHelper.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs b/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs index ee71f1002a958..cf843526fb3c2 100644 --- a/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs +++ b/src/libraries/Common/src/System/Collections/Generic/BitHelper.cs @@ -20,18 +20,20 @@ internal BitHelper(Span span, bool clear) internal void MarkBit(int bitPosition) { uint bitArrayIndex = (uint)bitPosition / IntSize; - if (bitArrayIndex < (uint)_span.Length) + Span 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 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; } /// How many ints must be allocated to represent n bits. Returns (n+31)/32, but avoids overflow.