Skip to content

Commit

Permalink
refactor: cleaner header parsing
Browse files Browse the repository at this point in the history
Builds off seanmonstar#134 (swar), seanmonstar#138 (Bytes cursor)

Cleaner, faster and less macros !

- Broke down header-parsing into clean conceptual steps (whilst being faster !)
- Added InnerResult allowing for idiomatic `?` early-exits, removing need for parsing-helper macros
- Removed macros.rs, leaving only `byte_map!` (response header-parsing macros should become functions)
  • Loading branch information
AaronO committed Jun 1, 2023
1 parent 9ef6d3e commit d9cf6a3
Show file tree
Hide file tree
Showing 4 changed files with 353 additions and 250 deletions.
6 changes: 5 additions & 1 deletion benches/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ fn version(c: &mut Criterion) {
.bench_function(name, |b| b.iter(|| {
black_box({
let mut b = httparse::_benchable::Bytes::new(input);
httparse::_benchable::parse_version(&mut b).unwrap()
match httparse::_benchable::parse_version(&mut b) {
// Somewhat awkward, but this is internal code so it's ok.
Ok(_) | Err(None) => (),
Err(Some(e)) => panic!("parse_version failed: {}", e),
}
});
}));
}
Expand Down
Loading

0 comments on commit d9cf6a3

Please sign in to comment.