From 5af5ba263d254a223f7479e802a98c02469e5012 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 21:38:41 +0000 Subject: [PATCH] perf: optimize string allocations in casing.rs - Replace `.collect::>().join("")` with `.collect::()` in `Casing::Pascal` to eliminate an intermediate vector allocation. - Replace `.collect::()` with `.to_string()` in `camel_case` for more direct display conversion. Co-authored-by: cloudesize67-cmd <237356855+cloudesize67-cmd@users.noreply.github.com> --- xdk-lib/src/casing.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/xdk-lib/src/casing.rs b/xdk-lib/src/casing.rs index 6463487e..c334165e 100644 --- a/xdk-lib/src/casing.rs +++ b/xdk-lib/src/casing.rs @@ -29,11 +29,8 @@ impl Casing { result } } - Casing::Pascal => words - .iter() - .map(|w| pascal_case(w)) - .collect::>() - .join(""), + // ⚡ Bolt: Use .collect::() instead of .collect::>().join("") to eliminate an unnecessary intermediate vector allocation + Casing::Pascal => words.iter().map(|w| pascal_case(w)).collect::(), Casing::Kebab => words.join("-").to_lowercase(), Casing::ScreamingSnake => words.join("_").to_uppercase(), } @@ -118,6 +115,7 @@ 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(), + // ⚡ Bolt: Use .to_string() instead of .collect::() for more direct allocation using Display + Some(first) => first.to_lowercase().to_string() + chars.as_str(), } }