Skip to content

Commit 9b74f42

Browse files
authored
Tiny improvement of StringBuilder.Append(StringBuilder) (#101020)
* Update StringBuilder.cs * Add an assert to validate `ExpandByABlock` working as expected
1 parent eafac6f commit 9b74f42

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,8 @@ private StringBuilder AppendCore(StringBuilder value, int startIndex, int count)
846846
if (length == 0)
847847
{
848848
ExpandByABlock(count);
849-
length = Math.Min(m_ChunkChars.Length - m_ChunkLength, count);
849+
Debug.Assert(m_ChunkLength == 0 && m_ChunkChars.Length >= count);
850+
length = count;
850851
}
851852
value.CopyTo(startIndex, new Span<char>(m_ChunkChars, m_ChunkLength, length), length);
852853

0 commit comments

Comments
 (0)