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(), } }