Skip to content

Commit 831f795

Browse files
vimpunkSimonSapin
authored andcommitted
Address code review
1 parent 4d0a625 commit 831f795

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

src/from_bytes.rs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,23 @@ where
3838
E: EncodingSupport,
3939
{
4040
// https://drafts.csswg.org/css-syntax/#the-input-byte-stream
41-
match protocol_encoding_label {
42-
None => (),
43-
Some(label) => match E::from_label(label) {
44-
None => (),
45-
Some(protocol_encoding) => return protocol_encoding,
46-
},
47-
}
41+
if let Some(label) = protocol_encoding_label {
42+
if let Some(protocol_encoding) = E::from_label(label) {
43+
return protocol_encoding;
44+
};
45+
};
46+
4847
let prefix = b"@charset \"";
4948
if css.starts_with(prefix) {
5049
let rest = &css[prefix.len()..];
51-
match rest.iter().position(|&b| b == b'"') {
52-
None => (),
53-
Some(label_length) => {
54-
if rest[label_length..].starts_with(b"\";") {
55-
let label = &rest[..label_length];
56-
match E::from_label(label) {
57-
None => (),
58-
Some(charset_encoding) => {
59-
if E::is_utf16_be_or_le(&charset_encoding) {
60-
return E::utf8();
61-
} else {
62-
return charset_encoding;
63-
}
64-
}
50+
if let Some(label_length) = rest.iter().position(|&b| b == b'"') {
51+
if rest[label_length..].starts_with(b"\";") {
52+
let label = &rest[..label_length];
53+
if let Some(charset_encoding) = E::from_label(label) {
54+
if E::is_utf16_be_or_le(&charset_encoding) {
55+
return E::utf8();
56+
} else {
57+
return charset_encoding;
6558
}
6659
}
6760
}

src/parser.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
354354
..
355355
}) => Ok(()),
356356
Err(e) => unreachable!("Unexpected error encountered: {:?}", e),
357-
Ok(t) => Err(start
358-
.source_location()
359-
.new_basic_unexpected_token_error(t.clone())),
357+
Ok(t) => Err(start.source_location().new_basic_unexpected_token_error(t.clone())),
360358
};
361359
self.reset(&start);
362360
result

0 commit comments

Comments
 (0)