[AI Codemod][PerfAICT-ObjCpy] perf: Add extra && qualified overloads to RequestBuilder#28053
Open
MatzeB wants to merge 1 commit into
Open
[AI Codemod][PerfAICT-ObjCpy] perf: Add extra && qualified overloads to RequestBuilder#28053MatzeB wants to merge 1 commit into
MatzeB wants to merge 1 commit into
Conversation
…to RequestBuilder Summary: This code has been flagged for performance in internal profiles. This is an AI generated improvement that was human reviewed: Optimized `RequestBuilder` in `HttpClient.h` to avoid unnecessary copy construction when chaining builder methods on temporary (rvalue) objects. **Problem:** The builder methods (`jwtOptions`, `method`, `url`, `header`) returned `RequestBuilder&` (lvalue reference). When chaining on a temporary (e.g., `auto rb = RequestBuilder().method(...).url(...);`), the final result was an lvalue reference, forcing the implicit copy constructor to be invoked. **Fix:** Added `&&`-qualified (rvalue ref-qualified) overloads of all builder methods. When called on an rvalue `RequestBuilder`, these overloads return `RequestBuilder&&`, enabling move construction instead of copy construction at call sites like `PrestoExchangeSource::doRequest`. The existing `&`-qualified overloads continue to work identically for lvalue usage. This eliminates the copy of both `JwtOptions` and `proxygen::HTTPMessage` members in the common temporary-chaining pattern. Differential Revision: D107396503
|
Contributor
Reviewer's GuideAdds rvalue-reference-qualified overloads to RequestBuilder’s fluent builder methods so that chaining on temporaries returns RequestBuilder&& and avoids unnecessary copies, while preserving existing lvalue behavior. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new && and & overload pairs all duplicate the same bodies; consider factoring the shared logic into private helper methods (e.g.,
setJwtOptions,setMethod,setUrl,setHeader) to keep behavior in sync and reduce the chance of divergence when these are modified in the future.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new && and & overload pairs all duplicate the same bodies; consider factoring the shared logic into private helper methods (e.g., `setJwtOptions`, `setMethod`, `setUrl`, `setHeader`) to keep behavior in sync and reduce the chance of divergence when these are modified in the future.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
This code has been flagged for performance in internal profiles. This is an AI generated improvement that was human reviewed:
Optimized
RequestBuilderinHttpClient.hto avoid unnecessary copy construction when chaining builder methods on temporary (rvalue) objects.Problem: The builder methods (
jwtOptions,method,url,header) returnedRequestBuilder&(lvalue reference). When chaining on a temporary (e.g.,auto rb = RequestBuilder().method(...).url(...);), the final result was an lvalue reference, forcing the implicit copy constructor to be invoked.Fix: Added
&&-qualified (rvalue ref-qualified) overloads of all builder methods. When called on an rvalueRequestBuilder, these overloads returnRequestBuilder&&, enabling move construction instead of copy construction at call sites likePrestoExchangeSource::doRequest. The existing&-qualified overloads continue to work identically for lvalue usage. This eliminates the copy of bothJwtOptionsandproxygen::HTTPMessagemembers in the common temporary-chaining pattern.Differential Revision: D107396503
Summary by Sourcery
Enhancements: