From 79dffa2650a9e4380bbff218324db9eefd6a9bfa Mon Sep 17 00:00:00 2001 From: Praveen Perera Date: Fri, 31 Jan 2025 17:10:17 -0600 Subject: [PATCH] Remove`itertools` dependency, make unique more efficient --- Cargo.lock | 25 ++++++++++++------------- Cargo.toml | 6 ++++-- rustywind-cli/Cargo.toml | 3 --- rustywind-cli/src/options.rs | 2 -- rustywind-core/CHANGELOG.md | 6 ++++++ rustywind-core/Cargo.toml | 6 +++--- rustywind-core/src/app.rs | 13 +++++++------ 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0dd0e9b..a67b8e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -407,15 +407,6 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -640,7 +631,6 @@ dependencies = [ "eyre", "ignore", "indoc", - "itertools", "log", "once_cell", "rayon", @@ -653,16 +643,16 @@ dependencies = [ [[package]] name = "rustywind_core" -version = "0.2.1" +version = "0.3.0" dependencies = [ "ahash", "aho-corasick", "eyre", - "itertools", "once_cell", "pretty_assertions", "regex", "test-case", + "winnow", ] [[package]] @@ -1122,6 +1112,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" +dependencies = [ + "memchr", +] + [[package]] name = "yansi" version = "1.0.1" diff --git a/Cargo.toml b/Cargo.toml index 0696e1e..5542c58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,6 @@ repository = "https://github.com/avencera/rustywind" [workspace.dependencies] once_cell = "1.20" -regex = "1.11" -itertools = "0.13" # hashmap ahash = "0.8" @@ -26,6 +24,10 @@ color-eyre = "0.6" env_logger = "0.11" log = "0.4" +# regex +regex = "1.11" + + [profile.release] codegen-units = 1 lto = "fat" diff --git a/rustywind-cli/Cargo.toml b/rustywind-cli/Cargo.toml index 1658c1c..b28cc39 100644 --- a/rustywind-cli/Cargo.toml +++ b/rustywind-cli/Cargo.toml @@ -22,9 +22,6 @@ rustywind_vite = { path = "../rustywind-vite" } # rustywind_core = { version = "0.3" } # rustywind_vite = { version = "0.3" } -# iter -itertools = { workspace = true } - # utils regex = { workspace = true } once_cell = { workspace = true } diff --git a/rustywind-cli/src/options.rs b/rustywind-cli/src/options.rs index 364ae4a..b2e6df3 100644 --- a/rustywind-cli/src/options.rs +++ b/rustywind-cli/src/options.rs @@ -2,7 +2,6 @@ use clap::ValueEnum; use color_eyre::Help; use eyre::{Context, Result}; use ignore::WalkBuilder; -use itertools::Itertools; use regex::Regex; use rustywind_core::class_wrapping::ClassWrapping; use rustywind_core::RustyWind; @@ -183,7 +182,6 @@ fn get_search_paths_from_starting_paths(starting_paths: &[PathBuf]) -> Vec String { let extracted_classes = self.unwrap_wrapped_classes(class_string); - let sorted = if self.allow_duplicates { - self.sort_classes_vec(extracted_classes.into_iter()) - } else { - self.sort_classes_vec(extracted_classes.into_iter().unique()) - }; + let mut sorted = self.sort_classes_vec(extracted_classes.into_iter()); + + if !self.allow_duplicates { + sorted.dedup(); + } self.rewrap_wrapped_classes(sorted) } @@ -95,10 +94,12 @@ impl RustyWind { ClassWrapping::CommaSingleQuotes => classes .iter() .map(|class| format!("'{}'", class)) + .collect::>() .join(", "), ClassWrapping::CommaDoubleQuotes => classes .iter() .map(|class| format!("\"{}\"", class)) + .collect::>() .join(", "), } }