Skip to content

escape: speed up URL encoding and decoding - #22780

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/escape-more
Closed

bagder wants to merge 2 commits into
masterfrom
bagder/escape-more

Conversation

@bagder

@bagder bagder commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

(fastest of three runs)

branch: master

URL encode

Time/loop: 2082.52 ns

URL decode (fastest of three runs)

Time/loop: 612.65 ns

branch: this PR

URL encode

Time/loop: 388.95 ns (-81%)

URL decode

Time/loop: 328.88 ns (-46%)

@bagder
bagder requested a balanced review from Copilot September 1, 2026 14:44
@bagder
bagder marked this pull request as ready for review September 1, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

Pull request overview

Optimizes URL escaping by batching consecutive unreserved characters, improving percent-encoding performance.

Changes:

  • Tracks contiguous unreserved input spans.
  • Appends spans in bulk while encoding reserved bytes individually.
File summaries
File Description
lib/escape.c Batches dynamic-buffer appends during URL escaping.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bagder

This comment was marked as outdated.

@bagder
bagder force-pushed the bagder/escape-more branch from cc9e11e to 47731c3 Compare September 2, 2026 22:03
@bagder bagder changed the title escape: add larger chunks of the source if possible escape: speed up URL encoding and decoding Sep 2, 2026
Primarily thanks to a new loopup table and taking bigger chunks to work
on instead of byte-by-byte, this PR does decoding twice as fast as
before and it encodes five times faster (on my x86-64).

Closes #22780
@bagder
bagder force-pushed the bagder/escape-more branch from d1d9df2 to fc10333 Compare September 3, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The reviewed optimization is covered by updated tests with no unresolved issues.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@bagder bagder closed this in 48e1964 Sep 3, 2026
@bagder
bagder deleted the bagder/escape-more branch September 3, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants