-
Notifications
You must be signed in to change notification settings - Fork 1.3k
avoid cloning the uri/path #2971
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
Conversation
47e0831 to
c618dab
Compare
mladedav
left a comment
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.
Looks good.
jplatte
left a comment
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 wonder whether we should run any benchmarking on this. In theory this could regress things as the request parts are moved around more (into_parts, from_parts).
I don't think this could regress things.
#[inline]
pub fn into_parts(self) -> (Parts, T) {
(self.head, self.body)
}and #[inline]
pub fn from_parts(parts: Parts, body: T) -> Request<T> {
Request { head: parts, body }
}Both should be no-op. |
|
Both will involve moving things around on the stack, which is not a no-op. In many cases such moves are optimized out when compiling with optimizations, but it's not guaranteed. |
|
I don't have the expertise for this. |
|
Okay, I'll look into it a bit later, if time permits. I think we have some existing benchmarks that I can run, probably need to add some more to distinguish short / long paths. |
|
Ran benchmarks locally, the most pronounced result was an improvement for the only test that has a >8 byte long path. Mixed results for other benchmarks, likely just noise. |
extract of #2865