Skip to content

Commit

Permalink
Tiny improvement of StringBuilder.Append(StringBuilder) (#101020)
Browse files Browse the repository at this point in the history
* Update StringBuilder.cs

* Add an assert to validate `ExpandByABlock` working as expected
  • Loading branch information
skyoxZ authored Jun 5, 2024
1 parent eafac6f commit 9b74f42
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ private StringBuilder AppendCore(StringBuilder value, int startIndex, int count)
if (length == 0)
{
ExpandByABlock(count);
length = Math.Min(m_ChunkChars.Length - m_ChunkLength, count);
Debug.Assert(m_ChunkLength == 0 && m_ChunkChars.Length >= count);
length = count;
}
value.CopyTo(startIndex, new Span<char>(m_ChunkChars, m_ChunkLength, length), length);

Expand Down

0 comments on commit 9b74f42

Please sign in to comment.