Skip to content

Conversation

@Phillip9587
Copy link
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.

Copy link

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


return function queryparse (body, encoding) {
return function parse (body, encoding) {
if (!body.length) return {}
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

The empty-body check !body.length may not handle all falsy cases correctly. Consider using !body || !body.length to handle cases where body might be null or undefined, ensuring consistent behavior with the original implementation.

Suggested change
if (!body.length) return {}
if (!body || !body.length) return {}

Copilot uses AI. Check for mistakes.
@Phillip9587 Phillip9587 requested a review from a team October 27, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant