Skip to content

[Feature]: ReadOnlySpan<char> across the board #120

@iXab3r

Description

@iXab3r

Pre-submission Checklist

  • I have read the README features list
  • I have read the FAQ Wiki
  • I have searched existing issues and this feature hasn't been requested
  • I have verified this feature doesn't already exist in the package

Problem Statement

Migrating from ImGuiNet to Hexa.NET we've noticed that there are no overloads accepting ReadOnlySpan<char>, this makes migration more complex than it potentially could be

Methods like Utils.EncodeStringUTF8 and Utils.GetByteCountUTF8 are also working only with strings, yet underlying Encoding.UTF8 method do have ReadOnlySpan<char> overloads.

Proposed Solution

Hexa.NET.Utilities

  • add overloads to Utils accepting ReadOnlySpan<char> - this is where the core logic will be moved
  • existing methods working with string will use AsSpan() extension method on supplied strings. It does not allocate

Hexa.NET.ImGui

  • same approach, my current understanding is that it will require mostly manual work in Manual/Functions/Functions.*.cs but please correct me if I am wrong

I have not digger deep enough yet into code generation part of the framework, I would assume same idea could be used there as well.

If you'll approve this I am happy to try to contribute

Alternatives Considered

Using ReadOnlySpan<byte> (and u8) is the most performant way of working with strings, but the tooling around it is very rough yet. If we're talking about software which tries to balance between convenience and performance, ReadOnlySpan<char> is usually the way to go.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions