Skip to content

Commit

Permalink
Use itertools
Browse files Browse the repository at this point in the history
  • Loading branch information
marxin committed Sep 13, 2024
1 parent 7089cc0 commit 41425b9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions linker-diff/src/header_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::Result;
use anyhow::anyhow;
use anyhow::bail;
use anyhow::Context as _;
use itertools::Itertools;
use linker_utils::elf::shf;
use linker_utils::elf::SectionFlags;
use object::elf::*;
Expand Down Expand Up @@ -223,10 +224,7 @@ pub(crate) fn diff_fields(
table_name: &str,
diff_mode: DiffMode,
) -> Vec<Diff> {
let field_values = objects
.iter()
.map(get_fields_fn)
.collect::<Vec<Result<FieldValues>>>();
let field_values = objects.iter().map(get_fields_fn).collect_vec();
if diff_mode == DiffMode::IgnoreIfAllErrors && field_values.iter().all(|d| d.is_err()) {
return vec![];
}
Expand Down
4 changes: 1 addition & 3 deletions linker-diff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,7 @@ fn short_file_display_names(config: &Config) -> Result<Vec<String>> {
}
names = names
.iter()
.map(|name| {
String::from_utf8_lossy(&name.bytes().skip(n).collect::<Vec<u8>>()).into_owned()
})
.map(|name| String::from_utf8_lossy(&name.bytes().skip(n).collect_vec()).into_owned())
.collect_vec();
Ok(names)
}
Expand Down
3 changes: 2 additions & 1 deletion wild_lib/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ mod tests {
use super::IGNORED_FLAGS;
use crate::args::Action;
use crate::args::InputSpec;
use itertools::Itertools;
use std::num::NonZeroUsize;
use std::path::Path;
use std::path::PathBuf;
Expand Down Expand Up @@ -727,7 +728,7 @@ mod tests {
InputSpec::File(_) => None,
InputSpec::Lib(lib_name) => Some(lib_name.as_ref()),
})
.collect::<Vec<&str>>(),
.collect_vec(),
&["gcc_s", "util", "rt", "pthread", "m", "dl", "c"]
);
assert_contains(&args.lib_search_path, "/lib");
Expand Down
2 changes: 1 addition & 1 deletion wild_lib/src/output_section_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ impl<'data> OutputSectionsBuilder<'data> {
}

pub(crate) fn with_base_address(base_address: u64) -> Self {
let section_infos: Vec<_> = SECTION_DEFINITIONS
let section_infos = SECTION_DEFINITIONS
.iter()
.map(|d| SectionOutputInfo {
section_flags: d.section_flags,
Expand Down
2 changes: 1 addition & 1 deletion wild_lib/src/symbol_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<'data> SymbolDb<'data> {
let num_symbols_per_group = groups
.iter()
.map(|g| g.files.iter().map(|f| f.num_symbols()).sum())
.collect::<Vec<usize>>();
.collect_vec();

let num_symbols = num_symbols_per_group.iter().sum();

Expand Down

0 comments on commit 41425b9

Please sign in to comment.