Skip to content

Removing unsafe code #56534

Closed
Closed
@ladeak

Description

@ladeak

Summary

Methods in StringUtilities.cs could have implementation without 'unsafe' keyword. It would allow HttpUtilities.GetHeaderName to also become safe as .NET 9 supports passing Span<T> (to generic type parameters).

Motivation and goals

Code becomes somewhat safer, no pointer arithmetic required, no 'pinning' by fixed would be required.

In scope

TryGetAsciiString could use Span<T> instead of char* and byte*, and methods using this could also become safe.

Risks / unknowns

It would still require a fair amount of Unsafe.As<> and Vector256.LoadUnsafe, MemoryMarshal.Cast etc.
The code is perf sensitive, but I believe the safe code would be still on-par with perf.

Other consideration

Could also consider adding Vector512 support on the way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsdesign-proposalThis issue represents a design proposal for a different issue, linked in the description

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions