Skip to content

[AI Codemod][PerfAICT-ObjCpy] perf: Add extra && qualified overloads to RequestBuilder#28053

Open
MatzeB wants to merge 1 commit into
prestodb:masterfrom
MatzeB:export-D107396503
Open

[AI Codemod][PerfAICT-ObjCpy] perf: Add extra && qualified overloads to RequestBuilder#28053
MatzeB wants to merge 1 commit into
prestodb:masterfrom
MatzeB:export-D107396503

Conversation

@MatzeB

@MatzeB MatzeB commented Jun 23, 2026

Copy link
Copy Markdown

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

Summary by Sourcery

Enhancements:

  • Add &&-qualified overloads for jwtOptions, method, url, and header to support efficient chaining on rvalue RequestBuilder instances while preserving existing lvalue behavior.

…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
@MatzeB MatzeB requested review from a team as code owners June 23, 2026 23:27
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@sourcery-ai

sourcery-ai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds 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

Change Details Files
Introduce &&-qualified overloads for RequestBuilder fluent methods to enable move-based chaining on temporaries while keeping existing &-qualified behavior for lvalues.
  • Ref-qualify existing jwtOptions, method, url, and header overloads with & so they only participate for lvalue RequestBuilder instances
  • Add matching &&-qualified overloads for jwtOptions, method, url, and both header signatures that assign into internal members and return std::move(*this)
  • Maintain existing semantics of setting jwtOptions_, headers_.setMethod, headers_.setURL, and headers_.getHeaders().set while optimizing call sites that chain on temporaries
presto-native-execution/presto_cpp/main/http/HttpClient.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@steveburnett

Copy link
Copy Markdown
Contributor
  • Please sign the Presto CLA.

  • Please edit the PR title to follow semantic commit style to pass the failing and required CI check. See the failure in the test for advice. If you can’t edit the PR title let us know and we can help.

  • Please add a release note - or NO RELEASE NOTE - following the Release Notes Guidelines to pass the failing but not required CI check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants