-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tiny improvement of StringBuilder.Append(StringBuilder)
#101020
Conversation
Worth an assert to self document? |
My answer would rather be no. Perhaps runtime/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs Lines 2438 to 2446 in fa1164c
|
If we're making an assumption, we should add an assert to validate that assumption holds true long term. Otherwise, it is trivially possible for a bug to be introduced due to a later refactoring or change. |
Also relevant, in some places StringBuilder relies on use of unsafe code such that bounds mistakes could cause and in the past have caused heap corruption. It's another reason to assert assumptions a little more than you might in some other code. |
timeouts, let's try again |
it is guaranteed that
m_ChunkLength == 0
andm_ChunkChars.Length >= count
afterExpandByABlock(count);
.