Skip to content

Use more performant span APIs - #67150

Merged
MihaZupan merged 5 commits into
dotnet:mainfrom
martincostello:gh-19771
Jun 26, 2026
Merged

MihaZupan merged 5 commits into
dotnet:mainfrom
martincostello:gh-19771

Conversation

@martincostello

@martincostello martincostello commented Jun 11, 2026 •

Copy link
Copy Markdown
Member

Use more performant span APIs

Use some new span-based APIs in some remaining call sites.

Description

Changes:

  • Use SearchValues to search for invalid path characters in EmbeddedFileProvider and EmbeddedFilesManifest.
  • Use span-based methods in BindingAddress and UrlPrefix.

New analysers since 2022 have flushed out most of the possible improvements that existed at the time the issue was created, so these changes should allow the original issue to be closed off.

Fixes #39771

- Use `SearchValues` to search for invalid path characters in `EmbeddedFileProvider` and `EmbeddedFilesManifest`.
- Use span-based methods in `BindingAddress` and `UrlPrefix`.

Fixes dotnet#39771.
@github-actions github-actions Bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jun 11, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 11, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Comment thread src/Servers/HttpSys/src/UrlPrefix.cs Resolved
Comment thread src/Http/Http/src/BindingAddress.cs Resolved
Revert overlapping changes with dotnet#67018.
@MihaZupan
MihaZupan enabled auto-merge (squash) June 11, 2026 15:52
Copilot AI review requested due to automatic review settings June 25, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates a couple of remaining string-based parsing call sites to use more efficient APIs (char overloads / span-based comparisons) while preserving existing parsing behavior in core address/prefix parsing paths.

Changes:

  • UrlPrefix.Create now uses IndexOf(char, ...) / LastIndexOf(char, ...) instead of string + StringComparison.Ordinal for single-character searches.
  • BindingAddress.Parse now uses AsSpan(...).StartsWith(..., StringComparison.Ordinal) to detect unix/named pipe host prefixes without scanning the remainder of the string.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Servers/HttpSys/src/UrlPrefix.cs Switches single-character delimiter searches to char overloads in prefix parsing.
src/Http/Http/src/BindingAddress.cs Uses span-based StartsWith for pipe-prefix detection in address parsing.

@MihaZupan
MihaZupan merged commit 98928a7 into dotnet:main Jun 26, 2026
25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use ReadOnlySpan<char> equivalents for string methods?

3 participants