Skip to content

Conversation

mdsitton
Copy link
Contributor

This pull requests creates a ReadOnlySpan based AppendFormat for Utf16 only, this is for resolving #62

I attempted to implement a ReadOnlySpan based api for Utf8 but i found it too invasive to implement needing a lot of code duplication and rewriting of the core FormatParser specifically for utf-8 so that is not included. And without these deeper changes there would not be any performance improvement with including it so i've opted not to implement it, I will leave it up to someone else to try to implement it.

I've also not implemented a PreparedFormat api for this either, as the main purpose of this is to chain string builders together without creating a new string between them.

@neuecc
Copy link
Member

neuecc commented Dec 24, 2021

Does the String code also go through ReadOnlySpan?
Slow Span has a bad effect, especially in Unity, so I'd like to keep the String native code path.

@mdsitton
Copy link
Contributor Author

mdsitton commented Dec 24, 2021

I converted All of FormatParser to use Span inputs for everything. So it will likely have an impact.

I'll have to look at duplicating the the FormatParser completely for a string and ReadOnlySpan version to resolve this. Not ideal for code maintainability but it is what it is.

@mdsitton
Copy link
Contributor Author

mdsitton commented Dec 24, 2021

I think considerations should also start to be made for the unity 2021.2 and later which should support fast span now since they have moved to a newer version of mono with .net standard 2.1 support.

@mdsitton mdsitton force-pushed the SpanFormat branch 2 times, most recently from cc595d1 to 278f6f3 Compare December 24, 2021 12:22
@mdsitton
Copy link
Contributor Author

mdsitton commented Dec 24, 2021

Ok new changes should be good to go!

Edit:
Removed outdated benchmark info

@neuecc
Copy link
Member

neuecc commented Jan 4, 2022

thanks!
I'll merge soon and release it.

@neuecc neuecc merged commit 4ba6473 into Cysharp:master Jan 4, 2022
ThangwLee pushed a commit to WolffunGame/ZString that referenced this pull request May 26, 2023
Add ReadOnlySpan<char>based format AppendFormat for Utf16ValueStringBuilder
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.

2 participants