FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Avoid rebuilding clean query strings by pavel-ptashyts · Pull Request #2265 · AsyncHttpClient/async-http-client · GitHub

Avoid rebuilding clean query strings - #2265

Merged
hyperxpro merged 6 commits into
AsyncHttpClient:mainfrom
maygemdev:perf/lazy-query-encoding
Jul 24, 2026
Merged

Avoid rebuilding clean query strings#2265
hyperxpro merged 6 commits into
AsyncHttpClient:mainfrom
maygemdev:perf/lazy-query-encoding

Conversation

pavel-ptashyts commented Jul 19, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

  • add a lazy query-string encoder that reuses the input String when no escaping is needed
  • use that fast path for existing queries without additional query params
  • add tests for no-op query identity and query escaping

Rationale

UriEncoder already reuses the original Uri when encoding produces equal path and query values, but the existing query path still allocated a StringBuilder and replacement String for clean queries. The new helper mirrors the path encoder's lazy behavior and avoids that temporary allocation in the common already-encoded REST query case.

Validation

  • ./mvnw -pl client -Dtest=Utf8UrlEncoderTest,UriEncoderTest test
  • ./mvnw -pl client -DskipTests compile
  • ./mvnw -pl client -Dtest=UriTest,QueryParametersTest,PostWithQueryStringTest test

Attribution

Codex on behalf of Pavel Ptashyts

pavel-ptashyts force-pushed the perf/lazy-query-encoding branch from 2da5f56 to d2086e8 Compare July 20, 2026 08:50
pavel-ptashyts and others added 2 commits July 20, 2026 17:05
Add a lazy query-string encoder that mirrors the existing path encoder
fast path. When a query contains only pass-through characters,
UriEncoder now reuses the original String instead of allocating a
pooled StringBuilder and an equal replacement String.

The append-based path is unchanged for URLs with additional query
params. Existing escaping behavior is preserved for queries that
need percent-encoding.

Codex on behalf of Pavel Ptashyts

Co-Authored-By: Codex <codex@openai.com>
The lazy query encoder is an implementation detail used only by
UriEncoder and same-package tests. Publishing it would expand the
supported API without a caller-facing requirement.

Keep the allocation optimization while limiting the helper to its
package.

Codex on behalf of Pavel Ptashyts

Co-Authored-By: Codex <codex@openai.com>
pavel-ptashyts force-pushed the perf/lazy-query-encoding branch from 1e41fb2 to b4badf5 Compare July 20, 2026 15:08
Co-authored-by: Aayush Atharva <24762260+hyperxpro@users.noreply.github.com>
hyperxpro merged commit c309f37 into AsyncHttpClient:main Jul 24, 2026
13 checks passed
pavel-ptashyts deleted the perf/lazy-query-encoding branch July 25, 2026 10:35
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL