Skip to content

Commit d032dc3

Browse files
committed
Avoid matching on byte strings
This match didn't compile to efficient code (rust-lang/rust#110870). In the release build, this commit changes 10908: 49 8d 54 24 04 lea 0x4(%r12),%rdx 1090d: 80 3a 70 cmpb $0x70,(%rdx) 10910: 0f 85 2a 01 00 00 jne 10a40 10916: 41 80 7c 24 05 73 cmpb $0x73,0x5(%r12) 1091c: 0f 85 1e 01 00 00 jne 10a40 10922: 41 80 7c 24 06 73 cmpb $0x73,0x6(%r12) 10928: 0f 85 12 01 00 00 jne 10a40 1092e: 41 80 7c 24 07 68 cmpb $0x68,0x7(%r12) 10934: 0f 85 06 01 00 00 jne 10a40 to 108bb: 49 8d 5c 24 04 lea 0x4(%r12),%rbx <...> 10975: 81 3b 70 73 73 68 cmpl $0x68737370,(%rbx) 1097b: 0f 84 af 02 00 00 je 10c30
1 parent 07d7e6d commit d032dc3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/init_data.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ fn parse_cenc(boxes: &[u8]) -> Result<&[u8], InitDataError> {
104104
};
105105
let box_payload = checked_slice(remaining, payload_start..payload_end)?;
106106

107-
match box_type {
108-
b"pssh" => {
109-
if let Some(wv_pssh) = parse_pssh_box(box_payload)? {
110-
return Ok(wv_pssh);
111-
}
112-
}
113-
_ => warn!(
107+
if box_type != b"pssh" {
108+
warn!(
114109
"Skipping unknown CENC box type: {}",
115110
box_type.escape_ascii()
116-
),
111+
);
112+
continue;
113+
}
114+
115+
if let Some(wv_pssh) = parse_pssh_box(box_payload)? {
116+
return Ok(wv_pssh);
117117
}
118118

119119
remaining = &remaining[payload_end..];

0 commit comments

Comments
 (0)