alamb commented on code in PR #13691: URL: https://github.com/apache/datafusion/pull/13691#discussion_r1882903037
########## datafusion/functions/src/string/initcap.rs: ########## @@ -132,21 +132,22 @@ fn initcap_utf8view(args: &[ArrayRef]) -> Result<ArrayRef> { Ok(Arc::new(result) as ArrayRef) } -fn initcap_string(string: Option<&str>) -> Option<String> { - let mut char_vector = Vec::<char>::new(); - string.map(|string: &str| { - char_vector.clear(); - let mut previous_character_letter_or_number = false; - for c in string.chars() { - if previous_character_letter_or_number { - char_vector.push(c.to_ascii_lowercase()); +fn initcap_string(input: Option<&str>) -> Option<String> { + input.map(|s| { + let mut result = String::with_capacity(s.len()); Review Comment: FWIW we could likely make this function much faster still by using one of the StringArrayWriters directly (it would save this allocation entirely) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org