Skip to content

Commit c97520d

Browse files
committed
Use span.Clear instead of Fill(0)
1 parent e1a2cad commit c97520d

File tree

1 file changed

+6
-2
lines changed
  • src/libraries/System.Collections/src/System/Collections

1 file changed

+6
-2
lines changed

src/libraries/System.Collections/src/System/Collections/BitArray.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,13 @@ public void Set(int index, bool value)
335335
=========================================================================*/
336336
public void SetAll(bool value)
337337
{
338-
int fillValue = value ? -1 : 0;
339338
int arrayLength = GetInt32ArrayLengthFromBitLength(Length);
340-
m_array.AsSpan(0, arrayLength).Fill(fillValue);
339+
Span<int> span = m_array.AsSpan(0, arrayLength);
340+
if (value)
341+
span.Fill(-1);
342+
else
343+
span.Clear();
344+
341345
_version++;
342346
}
343347

0 commit comments

Comments
 (0)