From e224b3d45568cc4b72bea62943b390b8a8c96c49 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 21:21:21 +0000 Subject: [PATCH] perf: eliminate allocations in casing operations - Replace `.collect::>().join("")` with `.collect::()` when generating PascalCase strings to avoid unnecessary Vec allocation. - Replace `.to_lowercase().collect::()` with `.to_lowercase().to_string()` when lowercasing individual characters. Co-authored-by: cloudesize67-cmd <237356855+cloudesize67-cmd@users.noreply.github.com> --- xdk-lib/src/casing.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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(), } }