Skip to content

Commit

Permalink
chore: Fix clippy warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeljanov committed Feb 24, 2024
1 parent b5e6e99 commit 1131ef8
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 21 deletions.
6 changes: 2 additions & 4 deletions symphonia-bundle-mp3/src/layer3/codebooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ lazy_static! {
let len = table.codes.len() as u16;

// Generate values for the codebook.
let values: Vec<u16> = (0..len).into_iter()
.map(|i| mpeg_gen_value(i, table.wrap))
let values: Vec<u16> = (0..len).map(|i| mpeg_gen_value(i, table.wrap))
.collect();

// Generate the codebook.
Expand All @@ -596,8 +595,7 @@ lazy_static! {
let len = table.codes.len() as u16;

// Generate values for the codebook.
let values: Vec<u16> = (0..len).into_iter()
.map(|i| mpeg_gen_value(i, table.wrap))
let values: Vec<u16> = (0..len).map(|i| mpeg_gen_value(i, table.wrap))
.collect();

// Generate the codebook.
Expand Down
6 changes: 3 additions & 3 deletions symphonia-codec-aac/src/aac/codebooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn make_raw_codebook(table: &VlcTable) -> Codebook<Entry16x16> {
let len = table.codes.len() as u16;

// Generate the indicies for each code.
let indicies: Vec<u16> = (0..len).into_iter().collect();
let indicies: Vec<u16> = (0..len).collect();

// Generate the codebook.
let mut builder = CodebookBuilder::new(BitOrder::Verbatim);
Expand All @@ -585,7 +585,7 @@ where
let codebook = make_raw_codebook(table);

// Generate values for the codebook.
let values: Vec<C::ValueType> = (0..table.codes.len()).into_iter().map(f).collect();
let values: Vec<C::ValueType> = (0..table.codes.len()).map(f).collect();

C::new(codebook, values.into_boxed_slice())
}
Expand Down Expand Up @@ -656,7 +656,7 @@ lazy_static! {
let len = SCF_CODEBOOK_CODES.len() as u8;

// Generate the values for the codebook.
let values: Vec<u8> = (0..len).into_iter().collect();
let values: Vec<u8> = (0..len).collect();

// Generate the codebook.
let mut builder = CodebookBuilder::new(BitOrder::Verbatim);
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-vorbis/src/codebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl VorbisCodebook {

// Generate the values associated for each codeword.
// TODO: Should unused entries be 0 or actually the correct value?
let values: Vec<u32> = (0..codebook_entries).into_iter().collect();
let values: Vec<u32> = (0..codebook_entries).collect();

// Finally, generate the codebook with a reverse (LSb) bit order.
let mut builder = CodebookBuilder::new_sparse(BitOrder::Reverse);
Expand Down
2 changes: 1 addition & 1 deletion symphonia-codec-vorbis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn read_residue(bs: &mut BitReaderRtl<'_>, max_codebook: u8) -> Result<Residue>
let residue_type = bs.read_bits_leq32(16)? as u16;

match residue_type {
0 | 1 | 2 => Residue::try_read(bs, residue_type, max_codebook),
0..=2 => Residue::try_read(bs, residue_type, max_codebook),
_ => decode_error("vorbis: invalid residue type"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion symphonia-format-ogg/src/mappings/opus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl PacketParser for OpusPacketParser {
fn parse_next_packet_dur(&mut self, packet: &[u8]) -> u64 {
// See https://www.rfc-editor.org/rfc/rfc6716
// Read TOC (Table Of Contents) byte which is the first byte in the opus data.
let toc_byte = match packet.get(0) {
let toc_byte = match packet.first() {
Some(b) => b,
None => {
warn!("opus packet empty");
Expand Down
8 changes: 4 additions & 4 deletions symphonia-format-riff/src/aiff/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ impl CommonChunk {
Ok(PacketInfo::without_blocks(block_align as u16))
}
FormatData::Extensible(_) => {
return unsupported_error("aiff: packet info not implemented for format Extensible")
unsupported_error("aiff: packet info not implemented for format Extensible")
}
FormatData::Adpcm(_) => {
return unsupported_error("aiff: packet info not implemented for format Adpcm")
unsupported_error("aiff: packet info not implemented for format Adpcm")
}
}
}
Expand All @@ -140,7 +140,7 @@ impl ParseChunk for CommonChunk {
let sample_size = reader.read_be_i16()?;

let mut sample_rate: [u8; 10] = [0; 10];
let _res = reader.read_buf_exact(sample_rate.as_mut())?;
reader.read_buf_exact(sample_rate.as_mut())?;

let sample_rate = Extended::from_be_bytes(sample_rate);
let sample_rate = sample_rate.to_f64() as u32;
Expand Down Expand Up @@ -214,7 +214,7 @@ impl CommonChunkParser for ChunkParser<CommonChunk> {
let sample_size = source.read_be_i16()?;

let mut sample_rate: [u8; 10] = [0; 10];
let _res = source.read_buf_exact(sample_rate.as_mut())?;
source.read_buf_exact(sample_rate.as_mut())?;

let sample_rate = Extended::from_be_bytes(sample_rate);
let sample_rate = sample_rate.to_f64() as u32;
Expand Down
2 changes: 1 addition & 1 deletion symphonia-format-riff/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl PacketInfo {
pub fn next_packet(
reader: &mut MediaSourceStream,
packet_info: &PacketInfo,
tracks: &Vec<Track>,
tracks: &[Track],
data_start_pos: u64,
data_end_pos: u64,
) -> Result<Packet> {
Expand Down
2 changes: 1 addition & 1 deletion symphonia-metadata/src/vorbis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ lazy_static! {
/// Parse a string containing a base64 encoded FLAC picture block into a visual.
fn parse_base64_picture_block(encoded: &str, metadata: &mut MetadataBuilder) {
if let Some(data) = base64_decode(encoded) {
if let Err(_) = flac::read_picture_block(&mut BufReader::new(&data), metadata) {
if flac::read_picture_block(&mut BufReader::new(&data), metadata).is_err() {
warn!("invalid picture block data");
}
}
Expand Down
8 changes: 3 additions & 5 deletions symphonia-play/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn run(args: &ArgMatches) -> Result<i32> {
_ => OsStr::new("NoName"),
};

dump_visuals(&mut probed, &name);
dump_visuals(&mut probed, name);
}

// Select the operating mode.
Expand All @@ -206,11 +206,9 @@ fn run(args: &ArgMatches) -> Result<i32> {
let seek = if let Some(time) = args.value_of("seek") {
Some(SeekPosition::Time(time.parse::<f64>().unwrap_or(0.0)))
}
else if let Some(ts) = args.value_of("seek-ts") {
Some(SeekPosition::Timetamp(ts.parse::<u64>().unwrap_or(0)))
}
else {
None
args.value_of("seek-ts")
.map(|ts| SeekPosition::Timetamp(ts.parse::<u64>().unwrap_or(0)))
};

// Set the decoder options.
Expand Down

0 comments on commit 1131ef8

Please sign in to comment.