Skip to content
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
merged 21 commits into from
Jan 6, 2024

Conversation

NightOwl888
Copy link
Owner

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 used ValueStringBuilderIndexer were optimized to use stack and/or array pool when buffering the chars.

…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).
@NightOwl888 NightOwl888 merged commit 9eb1524 into main Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant