You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2025/09/19 22:36:54 UTC
(groovy) 01/02: Trivial refactor: use `String.repeat()` instead
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_5_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 062b7a8baf57ea5bd5fa85231e00a07c24352904
Author: Daniel Sun <su...@apache.org>
AuthorDate: Fri Sep 19 23:56:45 2025 +0900
Trivial refactor: use `String.repeat()` instead
(cherry picked from commit 187fb905eace4496af34218e6cbe5deec4bb354b)
---
.../org/apache/groovy/groovysh/jline/GroovyPosixCommands.java | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java
index dcf69ffeaf..84ce50145c 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java
@@ -523,9 +523,7 @@ public class GroovyPosixCommands extends PosixCommands {
if (username.length() > 8) {
username = new StringBuilder(username.substring(0, 8));
} else {
- for (int i = username.length(); i < 8; i++) {
- username.append(" ");
- }
+ username.append(" ".repeat(Math.max(0, 8 - username.length())));
}
StringBuilder group;
if (attributes.containsKey("group")) {
@@ -536,9 +534,7 @@ public class GroovyPosixCommands extends PosixCommands {
if (group.length() > 8) {
group = new StringBuilder(group.substring(0, 8));
} else {
- for (int i = group.length(); i < 8; i++) {
- group.append(" ");
- }
+ group.append(" ".repeat(Math.max(0, 8 - group.length())));
}
Number length = (Number) attributes.get("size");
if (length == null) {