Polish "Use String.repeat instead of explicit cycle"

See gh-31802
This commit is contained in:
Stéphane Nicoll
2023-12-18 13:58:14 +01:00
parent 63b2787da6
commit d0574197ea
7 changed files with 16 additions and 12 deletions

View File

@@ -462,7 +462,9 @@ public final class Type {
return "double";
case ARRAY:
StringBuilder stringBuilder = new StringBuilder(getElementType().getClassName());
stringBuilder.append("[]".repeat(Math.max(0, getDimensions())));
for (int i = getDimensions(); i > 0; --i) {
stringBuilder.append("[]");
}
return stringBuilder.toString();
case OBJECT:
case INTERNAL:

View File

@@ -218,7 +218,9 @@ public class ReflectUtils {
dimensions++;
}
StringBuilder brackets = new StringBuilder(className.length() - dimensions);
brackets.append("[".repeat(Math.max(0, dimensions)));
for (int i = 0; i < dimensions; i++) {
brackets.append('[');
}
className = className.substring(0, className.length() - 2 * dimensions);
String prefix = (dimensions > 0) ? brackets + "L" : "";