Skip to content
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

[Feature Request] Add a JsonWebToken Constructor that accepts ReadOnlyMemory representation of the encodedToken #2487

Closed
sruke opened this issue Feb 12, 2024 · 2 comments · Fixed by #2458
Assignees
Labels
Enhancement The issue is a new feature

Comments

@sruke
Copy link
Contributor

sruke commented Feb 12, 2024

Is your feature request related to a problem? Please describe.
The usage of String.Split to extract segments from the token is expensive as it creates new strings and leads to additional memory allocation.

Describe the solution you'd like

  • Introduce a JsonWebToken Constructor that accepts ReadOnlyMemory representation of the encodedToken. This would allow us to substitute string.Split with span.Slice which will avoid string creation.
  • Update existing constructors to call into ReadTokens(ReadOnlyMemory) to maintain a single code path and enable current implementations to take advantage of some of the improvements without making any changes.
@Saibamen
Copy link

I would love to see benchmarks

@sruke sruke linked a pull request Feb 12, 2024 that will close this issue
@sruke
Copy link
Contributor Author

sruke commented Feb 12, 2024

I would love to see benchmarks

Added benchmarks in the PR that I just linked to the GitHub issue and in the discussion board where a preview has been shared. Appreciate any feedback.

@Saibamen ^

@jennyf19 jennyf19 added Enhancement The issue is a new feature and removed needs attention untriaged labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The issue is a new feature
Projects
None yet
3 participants