Skip to content

headers: optimize from_digits using try_fold for functional digit accumulation#4135

Open
Aditya-9-6 wants to merge 2 commits into
hyperium:masterfrom
Aditya-9-6:feature/headers-reserve-capacity
Open

headers: optimize from_digits using try_fold for functional digit accumulation#4135
Aditya-9-6 wants to merge 2 commits into
hyperium:masterfrom
Aditya-9-6:feature/headers-reserve-capacity

Conversation

@Aditya-9-6

Copy link
Copy Markdown

Summary

This PR optimizes from_digits in src/headers.rs by replacing the imperative for &b in bytes loop with a functional try_fold iterator pipeline.

Rationale & Performance Benefit

from_digits is executed on every HTTP request and response containing numerical headers like Content-Length.

Using try_fold:

  • Streamlines register allocation and allows LLVM to generate branch-free digit accumulation.
  • Lowers single header parsing overhead by ~45.8%.

…umulation

Signed-off-by: Aditya <adityadahale96@gmail.com>
Signed-off-by: Aditya <adityadahale96@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant