neilconway commented on code in PR #20278:
URL: https://github.com/apache/datafusion/pull/20278#discussion_r2818047916


##########
datafusion/functions/src/unicode/lpad.rs:
##########
@@ -266,17 +292,28 @@ where
                     continue;
                 }
 
-                // Reuse buffer by clearing and refilling
-                graphemes_buf.clear();
-                graphemes_buf.extend(string.graphemes(true));
-
-                if length < graphemes_buf.len() {
-                    builder.append_value(graphemes_buf[..length].concat());
+                if string.is_ascii() {
+                    // ASCII fast path: byte length == character length
+                    let str_len = string.len();
+                    if length < str_len {

Review Comment:
   In my opinion I think this is okay as-is, especially now that we've switched 
to a `for` loop to add the padding.



##########
datafusion/functions/src/unicode/rpad.rs:
##########
@@ -234,6 +238,17 @@ where
                             let length = if length < 0 { 0 } else { length as 
usize };
                             if length == 0 {
                                 builder.append_value("");
+                            } else if string.is_ascii() {
+                                // ASCII fast path: byte length == character 
length
+                                let str_len = string.len();
+                                if length < str_len {

Review Comment:
   In my opinion I think this is okay as-is, especially now that we've switched 
to a `for` loop to add the padding.



-- 
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]

Reply via email to