Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Oct 17, 2023
1 parent c4d091d commit 6443539
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions crates/re_types_builder/src/codegen/cpp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ impl CppCodeGenerator {
&folder_path_sdk
};
let filepath = folder_path.join(format!("{filename_stem}.{extension}"));
let inserted = files_to_write.insert(filepath, contents);
let previous = files_to_write.insert(filepath, contents);
assert!(
inserted.is_none(),
previous.is_none(),
"Multiple objects with the same name: {:?}",
obj.name
);
Expand Down
14 changes: 5 additions & 9 deletions crates/re_types_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,11 @@ pub fn generate_cpp_code(

files.par_iter().for_each(|(filepath, contents)| {
// There's more than cpp/hpp files in here, don't run clang-format on them!
let contents =
if filepath.extension() == Some("cpp") || filepath.extension() == Some("hpp") {
format_code(contents)
} else {
contents.clone()
};
let contents = if matches!(filepath.extension(), Some("cpp" | "hpp")) {
format_code(contents)
} else {
contents.clone()
};
crate::codegen::common::write_file(filepath, &contents);
});
}
Expand Down Expand Up @@ -459,9 +458,6 @@ pub fn generate_rust_code(

re_tracing::profile_function!();

// TODO(emilk): running `cargo fmt` once for each file is very slow.
// It would probably be faster to write all files to a temporary folder, run carg-fmt on
// that folder, and then copy the results to the final destination (if the files has changed).
files.par_iter().for_each(|(path, source)| {
write_file(path, source.clone());
});
Expand Down

0 comments on commit 6443539

Please sign in to comment.