Skip to content

Conversation

@bagder
Copy link
Member

@bagder bagder commented Dec 9, 2025

  • the length is already known by parent functions
  • avoids strlen() calls
  • avoids strchr() calls for trimming off newline characters

@bagder bagder marked this pull request as ready for review December 9, 2025 09:05
- the length is already known by parent functions
- avoids strlen() calls
- avoids strchr() calls for trimming off newline characters
@bagder bagder requested a review from Copilot December 9, 2025 09:19
@bagder
Copy link
Member Author

bagder commented Dec 9, 2025

augment review

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Comment augment review to trigger a new review at any time.

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 Curl_headers_push() function by adding a length parameter to eliminate redundant string operations. The length is already known by calling functions, so passing it directly avoids expensive strlen() calls and strchr() searches for line ending detection.

Key changes:

  • Added size_t hlen parameter to Curl_headers_push() function signature
  • Replaced strchr()-based newline detection with direct index-based trimming
  • Updated call sites to pass the length value (from curl_msnprintf return value and existing buffer length)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/headers.h Updated function declaration to include the new hlen parameter
lib/headers.c Modified implementation to accept length parameter and replaced newline detection logic with more efficient character-by-character trimming from the end
lib/http2.c Updated call site to capture curl_msnprintf return value and pass it as the length parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder closed this in 4c36143 Dec 9, 2025
@bagder bagder deleted the bagder/push-len branch December 9, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant