Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Apr 22, 2023

Until we implement the Enum.TryFormat overload that targets UTF8, special-case enums in Utf8.TryWrite's handler to use the UTF16 TryFormat in order to avoid boxing the enum.

private byte[] _bytes = new byte[100];
private DayOfWeek _dow = DayOfWeek.Wednesday;

[Benchmark]
public bool TryWrite() => Utf8.TryWrite(_bytes, $"{_dow}", out _);
Method Job Toolchain Mean Error StdDev Ratio Allocated Alloc Ratio
TryWrite Job-IEGCCS \main\corerun.exe 34.06 ns 0.224 ns 0.209 ns 1.00 24 B 1.00
TryWrite Job-PGKARX \pr\corerun.exe 25.48 ns 0.164 ns 0.145 ns 0.75 - 0.00

Until we implement the Enum.TryFormat overload that targets UTF8, special-case enums in Utf8.TryWrite's handler to use the UTF16 TryFormat in order to avoid boxing the enum.
@stephentoub stephentoub added this to the 8.0.0 milestone Apr 22, 2023
@ghost ghost assigned stephentoub Apr 22, 2023
@ghost
Copy link

ghost commented Apr 22, 2023

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Until we implement the Enum.TryFormat overload that targets UTF8, special-case enums in Utf8.TryWrite's handler to use the UTF16 TryFormat in order to avoid boxing the enum.

Author: stephentoub
Assignees: -
Labels:

area-System.Runtime

Milestone: 8.0.0

@stephentoub stephentoub merged commit c8af27d into dotnet:main Apr 24, 2023
@stephentoub stephentoub deleted the utf8enumtemp branch April 24, 2023 15:37
@ghost ghost locked as resolved and limited conversation to collaborators May 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants