From 40b35704caa8815056f61a373ad85e57f0413d0f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:22:01 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[performance=20improvement]?= =?UTF-8?q?=20optimize=20string=20concatenation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced `.collect::>().join("")` with `.collect::()` and `.collect::()` with `.to_string()` for characters to bypass unnecessary intermediate memory allocations in the `casing.rs` module. Co-authored-by: cloudesize67-cmd <237356855+cloudesize67-cmd@users.noreply.github.com> --- .jules/bolt.md | 5 +++++ xdk-lib/src/casing.rs | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..5fb263fd --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,5 @@ +## 2024-05-30 - Optimize string concatenation + +**Learning:** Rust string iterators using `.collect::>().join("")` allocate an unnecessary intermediate vector. + +**Action:** Replace this pattern with `.collect::()` to bypass the intermediate vector allocation. diff --git a/xdk-lib/src/casing.rs b/xdk-lib/src/casing.rs index 6463487e..bd04c567 100644 --- a/xdk-lib/src/casing.rs +++ b/xdk-lib/src/casing.rs @@ -29,11 +29,7 @@ impl Casing { result } } - Casing::Pascal => words - .iter() - .map(|w| pascal_case(w)) - .collect::>() - .join(""), + Casing::Pascal => words.iter().map(|w| pascal_case(w)).collect::(), Casing::Kebab => words.join("-").to_lowercase(), Casing::ScreamingSnake => words.join("_").to_uppercase(), } @@ -118,6 +114,6 @@ pub fn camel_case(value: &str) -> String { let mut chars = pascal.chars(); match chars.next() { None => String::new(), - Some(first) => first.to_lowercase().collect::() + chars.as_str(), + Some(first) => first.to_lowercase().to_string() + chars.as_str(), } }