Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
darrell-roberts committed Nov 23, 2024
1 parent f95e0b9 commit 2cf6ea1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
13 changes: 4 additions & 9 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,22 @@ fn main() -> anyhow::Result<()> {
target_os,
};

let crate_parsed_data = parallel_parse(&parse_context, walker_builder, language_type);
let parsed_data = parallel_parse(&parse_context, walker_builder, language_type);

// Collect all the types into a map of the file name they
// belong too and the list of type names. Used for generating
// imports in generated files.
let import_candidates = if multi_file {
all_types(&crate_parsed_data)
all_types(&parsed_data)
} else {
HashMap::new()
};

check_parse_errors(&crate_parsed_data)?;
check_parse_errors(&parsed_data)?;

info!("typeshare started writing generated types");

write_generated(
destination,
lang.as_mut(),
crate_parsed_data,
import_candidates,
)?;
write_generated(destination, lang.as_mut(), parsed_data, import_candidates)?;

info!("typeshare finished generating types");
Ok(())
Expand Down
5 changes: 2 additions & 3 deletions cli/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ fn parse_dir_entry(
.flatten()
}

/// Use parallel builder to walk all source directories
/// in parallel.
/// Use parallel builder to walk all source directories concurrently.
pub fn parallel_parse(
parse_context: &ParseContext,
walker_builder: WalkBuilder,
Expand All @@ -143,6 +142,7 @@ pub fn parallel_parse(

for parsed_data in rx {
let crate_name = parsed_data.crate_name.clone();
// Append each yielded parsed data by its respective crate.
*crate_parsed_data.entry(crate_name).or_default() += parsed_data;
}

Expand All @@ -151,7 +151,6 @@ pub fn parallel_parse(

walker_builder.build_parallel().run(|| {
let tx = tx.clone();
let parse_context = &parse_context;

Box::new(move |direntry_result| match direntry_result {
Ok(dir_entry) => {
Expand Down

0 comments on commit 2cf6ea1

Please sign in to comment.