-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Description
I benchmarked ZString against .NET built-in ValueStringBuilder (not exposed publicly but we can steal extract the sources from https://source.dot.net/#System.Text.RegularExpressions/src/libraries/Common/src/System/Text/ValueStringBuilder.cs,42c1e0215cccb8b1 )
For some cases (when knowing length upfront and when appending 1-char strings) ValueStringBuilder is much faster.
Steps needed:
- We should allow passing
capacitytoCreateStringBuilderto preallocate buffer if length is known - We should use an optimized path when
Appendis called with a 1-character string. Look at howValueStringBuilderdoes it. If length is1it just setsbuffer[pos++] = inputString[0]which is extremely fast, much faster than calling.CopyTo. https://source.dot.net/#System.Text.RegularExpressions/src/libraries/Common/src/System/Text/ValueStringBuilder.cs,42c1e0215cccb8b1
Metadata
Metadata
Assignees
Labels
No labels