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 Apr 25, 2023
1 parent e73b238 commit 637637b
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 253 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

0 comments on commit 637637b

Please sign in to comment.