snuyanzin commented on code in PR #29004:
URL: https://github.com/apache/flink/pull/29004#discussion_r3921540675


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java:
##########
@@ -345,29 +338,61 @@ public static String rpad(String base, int len, String 
pad) {
             return "";
         }
 
-        char[] data = new char[len];
-        char[] baseChars = base.toCharArray();
-        char[] padChars = pad.toCharArray();
+        final int baseEnd = endOfCodePoints(base, len);
+        final int padCount = len - base.codePointCount(0, baseEnd);

Review Comment:
   you iterate 2 times over prefix
   better to replace with something like this
   ```java
   final int length = base.length();
   int baseEnd = 0;
   int baseCodePoints = 0;
   while (baseCodePoints < len && baseEnd < length) {
       baseEnd += Character.charCount(base.codePointAt(baseEnd));
       baseCodePoints++;
   }
   final int padCount = len - baseCodePoints;
   ```



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

Reply via email to