All rules
CA1855Performance Enabled by default: As suggestion
Use Span\<T>.Clear() instead of Span\<T>.Fill()
Use Span\<T>.Clear() instead of Span\<T>.Fill()
Microsoft docsDescription
It's more efficient to call System.Span1.Clear than to call System.Span1.Fill(`0) to fill the elements of the span with a default value.
Cause
System.Span1.Fill(0) is called to fill the elements of a span with a default value.
How to fix violations
Replace the call to System.Span1.Fill(0) with a call to System.Span`1.Clear.
Example
void M(Span<byte> span)
{
span.Fill(0);
}
void M(Span<byte> span)
{
span.Clear();
}When to suppress
It's safe to suppress this warning if performance isn't a concern.
Your vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0