Skip to content
Discussion options

You must be logged in to vote

Note that MemoryManager does add rather unpleasant overhead that may not be suitable for something as performance-critical as a string primitive. After extensively evaluating all alternatives, I had to settle on Memory-like layout of byte[] + offset + length in U8String: https://github.com/U8String/U8String/blob/main/Sources/U8String/U8String.cs#L83-L84

It makes it easy to create ROM<byte> instances (you can even bitcast into them, though I'm feeling on the fence about it as it's UB which is not desirable) and works pretty well after struct handling improvements in .NET 8.

Once you have this building block, it becomes a non-issue to provide convenient API for pinning, marshalling, etc.

Mu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@josephmoresena
Comment options

Answer selected by josephmoresena
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants