From 136f85154039c5e43399ff562b5541c84be94be6 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Tue, 17 Oct 2023 15:08:20 +0200 Subject: [PATCH] pr comments --- crates/re_types_builder/src/codegen/cpp/mod.rs | 4 ++-- crates/re_types_builder/src/lib.rs | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/re_types_builder/src/codegen/cpp/mod.rs b/crates/re_types_builder/src/codegen/cpp/mod.rs index a6eb5429693c..e1dbf27c3ef9 100644 --- a/crates/re_types_builder/src/codegen/cpp/mod.rs +++ b/crates/re_types_builder/src/codegen/cpp/mod.rs @@ -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 ); diff --git a/crates/re_types_builder/src/lib.rs b/crates/re_types_builder/src/lib.rs index 589d0687b21e..bfc018af3350 100644 --- a/crates/re_types_builder/src/lib.rs +++ b/crates/re_types_builder/src/lib.rs @@ -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); }); } @@ -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()); });