neilconway commented on code in PR #20278:
URL: https://github.com/apache/datafusion/pull/20278#discussion_r2817987259
##########
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 {
+ builder.append_value(&string[..length]);
+ } else {
+ builder.write_str(string)?;
+ builder.append_value(
+ " ".repeat(length - str_len).as_str(),
+ );
Review Comment:
This benchmarked as slightly faster (~2-5%), I'll apply this here and
elsewhere (although I won't "commit suggestion" because we need
`append_value("")` still).
--
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]