Use String.repeat instead of explicit cycle

See gh-31802
This commit is contained in:
Adam Ostrožlík
2023-12-09 16:01:37 +01:00
committed by Stéphane Nicoll
parent 1ff683b259
commit 63b2787da6
7 changed files with 7 additions and 21 deletions

View File

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

View File

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