-
Notifications
You must be signed in to change notification settings - Fork 346
perf: remove heap allocation in parse_host #1021
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
perf: remove heap allocation in parse_host #1021
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1021 +/- ##
=======================================
Coverage ? 79.83%
=======================================
Files ? 24
Lines ? 4355
Branches ? 0
=======================================
Hits ? 3477
Misses ? 878
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@@ -80,15 +79,34 @@ impl Host<String> { | |||
/// | |||
/// <https://url.spec.whatwg.org/#host-parsing> | |||
pub fn parse(input: &str) -> Result<Self, ParseError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add, change, or remove from the public API, but please verify this as well in case I missed something.
/// and using Punycode as necessary. | ||
/// | ||
/// This process may fail. | ||
pub fn domain_to_ascii_from_cow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hsivonen Please check if you find this new public API of idna
to be acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gentle ping @hsivonen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's been several months, maybe this can be merged and then deprecated later if it's not the right approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Considering the code looks good, the perf gain is meaningful, and no-one has objected to the new API surface in 3 months, I am going to land this now.
Before:
After: