Skip to content

tool_getparam: simplify the --rate parser#20119

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/rate-parser
Closed

tool_getparam: simplify the --rate parser#20119
bagder wants to merge 2 commits into
masterfrom
bagder/rate-parser

Conversation

@bagder

@bagder bagder commented Dec 30, 2025

Copy link
Copy Markdown
Member

Avoids a memcpy()

@bagder bagder marked this pull request as ready for review December 30, 2025 22:48
@bagder bagder requested a review from Copilot December 30, 2025 22:48

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.

Pull request overview

This PR refactors the --rate parameter parser in set_rate() to simplify the parsing logic and eliminate an unnecessary memory copy operation. The changes replace a two-step approach (using strchr() to find the delimiter, then memcpy() to extract the number) with direct pointer-based parsing using curlx_str_number() and curlx_str_single().

  • Eliminates intermediate buffer allocation and memcpy() call
  • Changes denominator type from long to curl_off_t for consistency with parsing functions
  • Streamlines the parsing flow by using pointer advancement built into the parsing functions

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

@bagder bagder closed this in 23b0804 Jan 1, 2026
@bagder bagder deleted the bagder/rate-parser branch January 1, 2026 11:35
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