Skip to content

perf(urlencoded): move empty-body guard to avoid extra function closure - #647

Merged
jonchurch merged 1 commit into
expressjs:masterfrom
Phillip9587:urlencoded-remove-extra-closure
Jan 16, 2026
Merged

jonchurch merged 1 commit into
expressjs:masterfrom
Phillip9587:urlencoded-remove-extra-closure

Conversation

@Phillip9587

Copy link
Copy Markdown
Member

Inlines the empty-body check into the parser returned by createQueryParser, removing the extra wrapper function. The behavior is unchanged but we get a minor perf/alloc win by not creating a extra closure.

Copilot AI 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.

Pull Request Overview

This PR optimizes the URL-encoded body parsing by eliminating an extra function closure and moving the empty-body check directly into the parser function. The change improves performance by removing an unnecessary wrapper function while maintaining identical behavior.

  • Moves empty-body guard from wrapper function to main parser function
  • Eliminates extra function closure creation
  • Changes var to const for the parser assignment

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/types/urlencoded.js Resolved
@Phillip9587
Phillip9587 requested a review from a team October 27, 2025 20:20
@Phillip9587
Phillip9587 force-pushed the urlencoded-remove-extra-closure branch from aa99cd5 to 3694fbc Compare January 16, 2026 15:39
@jonchurch
jonchurch merged commit 8c36f57 into expressjs:master Jan 16, 2026
@Phillip9587
Phillip9587 deleted the urlencoded-remove-extra-closure branch January 16, 2026 20:48
This was referenced Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants