{
string s = m_value ? TrueLiteral : FalseLiteral;
- if (s.Length <= destination.Length)
+ if (s.AsReadOnlySpan().TryCopyTo(destination))
{
- bool copied = s.AsReadOnlySpan().TryCopyTo(destination);
- Debug.Assert(copied);
charsWritten = s.Length;
return true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static unsafe bool TryCopyTo(char* src, int length, Span<char> destination, out int charsWritten)
{
- if (length <= destination.Length)
+ if (new ReadOnlySpan<char>(src, length).TryCopyTo(destination))
{
- bool copied = new ReadOnlySpan<char>(src, length).TryCopyTo(destination);
- Debug.Assert(copied);
charsWritten = length;
return true;
}
if (thousandsSepCtr >= thousandsSepPos.Length)
{
var newThousandsSepPos = new int[thousandsSepPos.Length * 2];
- bool copied = thousandsSepPos.TryCopyTo(newThousandsSepPos);
- Debug.Assert(copied, "Expect copy to succeed, as the new array is larger than the original");
+ thousandsSepPos.CopyTo(newThousandsSepPos);
thousandsSepPos = newThousandsSepPos;
}
Grow(s.Length);
}
- bool copied = s.AsReadOnlySpan().TryCopyTo(_chars.Slice(pos));
- Debug.Assert(copied, "Grow should have made enough room to successfully copy");
+ s.AsReadOnlySpan().CopyTo(_chars.Slice(pos));
_pos += s.Length;
}
char[] poolArray = ArrayPool<char>.Shared.Rent(Math.Max(_pos + requiredAdditionalCapacity, _chars.Length * 2));
- bool success = _chars.TryCopyTo(poolArray);
- Debug.Assert(success);
+ _chars.CopyTo(poolArray);
char[] toReturn = _arrayToReturnToPool;
_chars = _arrayToReturnToPool = poolArray;