Dandandan commented on code in PR #21405:
URL: https://github.com/apache/datafusion/pull/21405#discussion_r3044021291
##########
datafusion/functions/src/unicode/rpad.rs:
##########
@@ -492,16 +484,15 @@ where
builder.append_value("");
}
} else {
- graphemes_buf.clear();
- graphemes_buf.extend(string.graphemes(true));
+ let char_count = string.chars().count();
- if target_len < graphemes_buf.len() {
- let end: usize =
- graphemes_buf[..target_len].iter().map(|g|
g.len()).sum();
- builder.append_value(&string[..end]);
+ if target_len < char_count {
+ builder.append_value(
+ &string[..byte_offset_of_char(string, target_len)],
+ );
} else {
builder.write_str(string)?;
- for _ in 0..(target_len - graphemes_buf.len()) {
+ for _ in 0..(target_len - char_count) {
Review Comment:
couldn't this use some `repeat` `extend` or something?
--
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]