Skip to content

Commit

Permalink
Fix the benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcdejonge committed Feb 10, 2025
1 parent 69c0d5b commit b508487
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
24 changes: 12 additions & 12 deletions benchmarks/benches/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ struct Header<'a> {

#[cfg_attr(rustfmt, rustfmt_skip)]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
fn is_token(c: u8) -> bool {
match c {
fn is_token(c: &u8) -> bool {
match *c {
128..=255 => false,
0..=31 => false,
b'(' => false,
Expand All @@ -48,23 +48,23 @@ fn is_token(c: u8) -> bool {
}
}

fn not_line_ending(c: u8) -> bool {
c != b'\r' && c != b'\n'
fn not_line_ending(c: &u8) -> bool {
*c != b'\r' && *c != b'\n'
}

fn is_space(c: u8) -> bool {
c == b' '
fn is_space(c: &u8) -> bool {
*c == b' '
}

fn is_not_space(c: u8) -> bool {
c != b' '
fn is_not_space(c: &u8) -> bool {
*c != b' '
}
fn is_horizontal_space(c: u8) -> bool {
c == b' ' || c == b'\t'
fn is_horizontal_space(c: &u8) -> bool {
*c == b' ' || *c == b'\t'
}

fn is_version(c: u8) -> bool {
c >= b'0' && c <= b'9' || c == b'.'
fn is_version(c: &u8) -> bool {
*c >= b'0' && *c <= b'9' || *c == b'.'
}

fn line_ending<'a>()-> impl Parser<&'a[u8], Output=&'a[u8], Error=Error<&'a[u8]>> {
Expand Down
24 changes: 12 additions & 12 deletions benchmarks/benches/http_streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ struct Header<'a> {

#[cfg_attr(rustfmt, rustfmt_skip)]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
fn is_token(c: u8) -> bool {
match c {
fn is_token(c: &u8) -> bool {
match *c {
128..=255 => false,
0..=31 => false,
b'(' => false,
Expand All @@ -48,23 +48,23 @@ fn is_token(c: u8) -> bool {
}
}

fn not_line_ending(c: u8) -> bool {
c != b'\r' && c != b'\n'
fn not_line_ending(c: &u8) -> bool {
*c != b'\r' && *c != b'\n'
}

fn is_space(c: u8) -> bool {
c == b' '
fn is_space(c: &u8) -> bool {
*c == b' '
}

fn is_not_space(c: u8) -> bool {
c != b' '
fn is_not_space(c: &u8) -> bool {
*c != b' '
}
fn is_horizontal_space(c: u8) -> bool {
c == b' ' || c == b'\t'
fn is_horizontal_space(c: &u8) -> bool {
*c == b' ' || *c == b'\t'
}

fn is_version(c: u8) -> bool {
c >= b'0' && c <= b'9' || c == b'.'
fn is_version(c: &u8) -> bool {
*c >= b'0' && *c <= b'9' || *c == b'.'
}

fn request_line(input: &[u8]) -> IResult<&[u8], Request<'_>> {
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/benches/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::str;

fn category(i: &[u8]) -> IResult<&[u8], &str> {
map_res(
delimited(char('['), take_while(|c| c != b']'), char(']')),
delimited(char('['), take_while(|c: &u8| *c != b']'), char(']')),
str::from_utf8,
)
.parse_complete(i)
Expand All @@ -28,8 +28,8 @@ fn key_value(i: &[u8]) -> IResult<&[u8], (&str, &str)> {
let (i, key) = map_res(alphanumeric, str::from_utf8).parse_complete(i)?;
let (i, _) = tuple((opt(space), char('='), opt(space))).parse_complete(i)?;
let (i, val) =
map_res(take_while(|c| c != b'\n' && c != b';'), str::from_utf8).parse_complete(i)?;
let (i, _) = opt(pair(char(';'), take_while(|c| c != b'\n'))).parse_complete(i)?;
map_res(take_while(|c: &u8| *c != b'\n' && *c != b';'), str::from_utf8).parse_complete(i)?;
let (i, _) = opt(pair(char(';'), take_while(|c: &u8| *c != b'\n'))).parse_complete(i)?;
Ok((i, (key, val)))
}

Expand Down

0 comments on commit b508487

Please sign in to comment.