Skip to content

Use pre-compiled regexp for matching Content-Type#12781

Merged
BagToad merged 1 commit intocli:trunkfrom
itchyny:api-compile-json-content
Mar 2, 2026
Merged

Use pre-compiled regexp for matching Content-Type#12781
BagToad merged 1 commit intocli:trunkfrom
itchyny:api-compile-json-content

Conversation

@itchyny
Copy link
Contributor

@itchyny itchyny commented Feb 25, 2026

Pre-compile the Content-Type regex used in processResponse to avoid
recompiling it on processing API response each time.

Copilot AI review requested due to automatic review settings February 25, 2026 10:45
@itchyny itchyny requested a review from a team as a code owner February 25, 2026 10:45
@itchyny itchyny requested a review from babakks February 25, 2026 10:45
@github-actions github-actions bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

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 optimizes gh api response handling by pre-compiling the JSON Content-Type matcher used in processResponse, avoiding repeated regexp compilation per response.

Changes:

  • Add a package-level pre-compiled regexp for matching JSON Content-Type values.
  • Switch processResponse from regexp.MatchString to (*regexp.Regexp).MatchString.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@itchyny itchyny force-pushed the api-compile-json-content branch from 2b037ef to 6057bfa Compare February 25, 2026 10:49
Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@BagToad BagToad merged commit 0f5355e into cli:trunk Mar 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team needs-triage needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants