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

Remove unnecessary string creations from OpenApiDocumentMiddleware #4553

Merged

Conversation

paulomorgado
Copy link
Contributor

Every time methods like string.Trim() or string.ToLowerInvariant() are invoked on an instance of a string, an new string instance is created.

Being a middleware, OpenApiDocumentMiddleware is on the hot path of every request.

This PR removes those string creations from OpenApiDocumentMiddleware.

To keep the same logic as before, `string.AsSpan()´ could be used, but that doesn't work as well on .NET Framework as in .NET, performance-wise.

@RicoSuter RicoSuter merged commit a099ebc into RicoSuter:master Oct 31, 2023
1 check passed
@RicoSuter
Copy link
Owner

Thanks for the pr

@paulomorgado paulomorgado deleted the OpenApiDocumentMiddleware-performance branch November 1, 2023 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants