Skip to content

Avoid Uri reallocation in UriEncoder.encode() on the no-op path#2204

Merged
hyperxpro merged 1 commit into
mainfrom
uriencoder-noop-allocation
Jun 20, 2026
Merged

Avoid Uri reallocation in UriEncoder.encode() on the no-op path#2204
hyperxpro merged 1 commit into
mainfrom
uriencoder-noop-allocation

Conversation

@hyperxpro

Copy link
Copy Markdown
Member

Motivation:

UriEncoder.encode() always built and returned a new Uri even when the URL was already encoded and no query params were added - the common case - allocating an identical copy on every such request.

Modification:

When the encoded path and query equal the input's, return the original Uri instead of constructing a copy (all other fields carry over unchanged).

Result:

No Uri allocation on the no-op encode path, which is the typical request; encoded output is unchanged.

@hyperxpro hyperxpro merged commit 971e4b5 into main Jun 20, 2026
29 of 30 checks passed
@hyperxpro hyperxpro deleted the uriencoder-noop-allocation branch June 20, 2026 20:35
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.

1 participant