-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add primitive type Span-based Parse/TryParse/TryFormat methods #22837
Comments
@stephentoub may I work on this? |
@WinCPP, sure, thanks. Note that this one will likely require lots of perf testing to verify existing parse/formatting functionality isn't regressed, as the right way to implement it is likely to make lots of small changes around the existing implementations to switch from using arrays to using spans so that both the array-based and span-based entrypoints can share the same mostly-existing code paths. |
@stephentoub yup I understand. |
@stephentoub I think I need to let go off this issue that I grabbed. Being remote, I think I am handicapped in knowing what is being done / what is to be done. And this one appears to be quite a big one to do by myself. Sorry for the haste... Although I can work collaboratively... |
Ok, thanks. |
The implementation of the parsing side of this is complete. The formatting side still needs to be done, and would benefit from corert's managed formatting implementation being ported to coreclr, where the formatting is currently done in native code in the runtime. |
Formatting work depends on https://github.com/dotnet/coreclr/issues/13544 |
Since we have new implementation of formatting in native coreclr (dotnet/coreclr#12894 and an in-progress one dotnet/coreclr#14646), is it better to port these native implementations to managed code other than port from corert? |
Separated decimal, double, and single TryFormat methods into their own issues. Everything else is complete as of dotnet/corefx#25307. |
Is there any reason char.TryParse wasn't updated? Or is it simply considered to niche to be worthwhile? |
Just because it doesn't really add value in that there's no actual parsing, just accessing a single character in the string. Instead of: if (char.TryParse(str, out char c))
{
Use(c);
} you just do: if (!string.IsNullOrEmpty(str))
{
Use(str[0]);
} |
Thanks @stephentoub I only just realised that char.Parse doesn't deal with strings of escape characters such as |
You mean that uses C# language rules to parse/interpret the string? I'm not aware of one in the .NET core libraries. You'd likely need to use Roslyn's APIs. |
Separated out of https://github.com/dotnet/corefx/issues/21281 for tracking purposes.
The text was updated successfully, but these errors were encountered: