Zero clippy warnings: fix all 32 remaining

- Iterator::find() replaces manual loops (6 sites)
- Index-only loops → iterators (4 sites)
- Identical if-blocks merged
- Box large MkvStream WriteState enum variant
- Vec macro initializers, late init fixes
- Unused fields prefixed with underscore (format spec fields)
- Dead code removed or documented

0 clippy warnings. 319 tests passing.
This commit is contained in:
MattJackson
2026-04-11 19:33:13 +00:00
parent 75f15cae62
commit f48b4925c1
27 changed files with 80 additions and 106 deletions
+1 -6
View File
@@ -101,12 +101,7 @@ impl CodecParser for Ac3Parser {
/// Find AC3/E-AC-3 syncword (0x0B77) in data.
fn find_ac3_sync(data: &[u8]) -> Option<usize> {
for i in 0..data.len().saturating_sub(1) {
if data[i] == 0x0B && data[i + 1] == 0x77 {
return Some(i);
}
}
None
(0..data.len().saturating_sub(1)).find(|&i| data[i] == 0x0B && data[i + 1] == 0x77)
}
/// Extract bsid from an AC-3/E-AC-3 frame starting at the syncword.
+3 -7
View File
@@ -70,16 +70,12 @@ pub fn find_dts_hd_ext_sync(data: &[u8]) -> Option<usize> {
if data.len() < 4 {
return None;
}
for i in 0..=data.len() - 4 {
if data[i] == DTS_HD_EXT_SYNC[0]
(0..=data.len() - 4).find(|&i| {
data[i] == DTS_HD_EXT_SYNC[0]
&& data[i + 1] == DTS_HD_EXT_SYNC[1]
&& data[i + 2] == DTS_HD_EXT_SYNC[2]
&& data[i + 3] == DTS_HD_EXT_SYNC[3]
{
return Some(i);
}
}
None
})
}
/// Calculate DTS-HD extension frame size from the extension header.
+11 -15
View File
@@ -110,15 +110,16 @@ impl CodecParser for H264Parser {
// pictureParameterSetLength = pps.len()
// pictureParameterSetNALUnit = pps
let mut record = Vec::new();
record.push(1); // configurationVersion
record.push(sps[1]); // profile
record.push(sps[2]); // compatibility
record.push(sps[3]); // level
record.push(0xFF); // 6 bits reserved (111111) + 2 bits lengthSizeMinusOne (11 = 3)
record.push(0xE1); // 3 bits reserved (111) + 5 bits numSPS (1)
record.push((sps.len() >> 8) as u8);
record.push(sps.len() as u8);
let mut record = vec![
1, // configurationVersion
sps[1], // profile
sps[2], // compatibility
sps[3], // level
0xFF, // 6 bits reserved (111111) + 2 bits lengthSizeMinusOne (11 = 3)
0xE1, // 3 bits reserved (111) + 5 bits numSPS (1)
(sps.len() >> 8) as u8,
sps.len() as u8,
];
record.extend_from_slice(sps);
record.push(1); // numPPS
record.push((pps.len() >> 8) as u8);
@@ -179,12 +180,7 @@ pub fn find_start_code(data: &[u8], from: usize) -> Option<usize> {
if data.len() < from + 3 {
return None;
}
for i in from..data.len() - 2 {
if data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01 {
return Some(i);
}
}
None
(from..data.len() - 2).find(|&i| data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01)
}
/// Skip past the start code at position `pos`, returning the first byte after it.
+1 -1
View File
@@ -70,7 +70,7 @@ mod tests {
fn header_skip_extracts_pcm_data() {
let mut parser = LpcmParser::new();
// 4-byte LPCM header + 6 bytes of PCM data
let header = vec![0x00, 0x01, 0x00, 0b10_01_0001]; // frame#=1, quant=24bit, rate=48k, ch=1
let header = vec![0x00, 0x01, 0x00, 0b1001_0001]; // frame#=1, quant=24bit, rate=48k, ch=1
let pcm_data = vec![0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE];
let mut pes_data = header;
pes_data.extend_from_slice(&pcm_data);
+1 -6
View File
@@ -195,12 +195,7 @@ fn find_start_code(data: &[u8], from: usize) -> Option<usize> {
if data.len() < from + 3 {
return None;
}
for i in from..data.len() - 2 {
if data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01 {
return Some(i);
}
}
None
(from..data.len() - 2).find(|&i| data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01)
}
#[cfg(test)]
+1 -6
View File
@@ -122,12 +122,7 @@ impl CodecParser for Vc1Parser {
}
fn find_next_sc(data: &[u8], from: usize) -> Option<usize> {
for i in from..data.len().saturating_sub(2) {
if data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01 {
return Some(i);
}
}
None
(from..data.len().saturating_sub(2)).find(|&i| data[i] == 0x00 && data[i + 1] == 0x00 && data[i + 2] == 0x01)
}
#[cfg(test)]