Skip to content

Commit 0eff4d1

Browse files
Avoid allocation when detecting content encoding
1 parent 54a0f3d commit 0eff4d1

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

crates/trusted-server-core/src/streaming_processor.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ impl Compression {
5252
/// Detect compression from content-encoding header
5353
#[must_use]
5454
pub fn from_content_encoding(encoding: &str) -> Self {
55-
match encoding.to_lowercase().as_str() {
56-
"gzip" => Self::Gzip,
57-
"deflate" => Self::Deflate,
58-
"br" => Self::Brotli,
59-
_ => Self::None,
55+
if encoding.eq_ignore_ascii_case("gzip") {
56+
Self::Gzip
57+
} else if encoding.eq_ignore_ascii_case("deflate") {
58+
Self::Deflate
59+
} else if encoding.eq_ignore_ascii_case("br") {
60+
Self::Brotli
61+
} else {
62+
Self::None
6063
}
6164
}
6265
}

0 commit comments

Comments
 (0)