-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
PERFORMANCE: Removed ValueStringBuilder and reworked methods that used it to use stack/array pool explicitly #85
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…e can track whether it makes sense to use the stack when comparing StringBuilder chars.
…tringBuilderIndexer to using stack/array pool for comparing chars
…gBuilderIndexer to using stack/array pool for comparing chars
…intAt() and CodePointBefore(): Updated documentation on StringBuilder overloads to recommend calling the ReadOnlySpan<char>, string, or char[] overload instead, since there is no way to optimize further (these methods are designed to be put inside of a loop).
…): Switched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
…r): Switched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
…lder): Switched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
…opy() instead of a for loop for better performance
…itched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
…f()): Switched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
… to ValueStringBuilderIndexer, since it negatively impacts performance
…ars out of the StringBuilder, then append them back in reverse order. This has much better performance than attempting to index through the StringBuilder to edit the chars in place. Use the stack if the length is short enough.
…nce + StringCharSequence)::Equals(): Switched from ValueStringBuilderIndexer to using stack/array pool for comparing chars
…BuilderIndexer to using stack/array pool for comparing chars
…ks() (when supported) to update the StringBuilder via index to keep from having to do a lookup on each character.
…scading calls because Insert(object?) and Append(object?) take precedence over extension methods that accept ICharSequence and StringBuilder. Added documentation to explain usage and added calls to cascade the call directly to the BCL, when supported and sensible.
…ing with pointers to Span<T> and ReadOnlySpan<T>
…rence() when dealing with pointers to Span<T> and ReadOnlySpan<T>
…ndexer, and ValueStringBuilderChunkedArrayIndexer.
… from StringBuilder overloads. There are no Insert() overloads that accept StringBuilder in the BCL (only Append).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfortunately,
ValueStringBuilderIndexer
didn't benchmark the same once it was compiled into J2N as it did when testing separately. I suspect it is due to inefficient IL code. In any case, this removes that implementation. Methods that previously usedValueStringBuilderIndexer
were optimized to use stack and/or array pool when buffering the chars.