comphead commented on code in PR #2102:
URL: https://github.com/apache/datafusion-comet/pull/2102#discussion_r2395607453
##########
native/spark-expr/src/static_invoke/char_varchar_utils/read_side_padding.rs:
##########
@@ -250,6 +271,10 @@ fn add_padding_string(
} else {
let pad_needed = length - char_len;
let pad: String =
pad_string.chars().cycle().take(pad_needed).collect();
- Ok(string + &pad)
+ if is_left_pad {
+ Ok(format!("{}{}", pad, string))
+ } else {
+ Ok(string + &pad)
+ }
Review Comment:
To avoid extra allocations we can try
```
let mut result = String::with_capacity(string.len() + pad.len());
if is_left_pad {
result.push_str(&pad);
result.push_str(&string);
} else {
result.push_str(&string);
result.push_str(&pad);
}
Ok(result)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]