From 8dce60ffac61bdfbf963e6ec0000cedef63986e8 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Sun, 1 Dec 2024 14:51:04 +0000 Subject: [PATCH] Simplify code: Using JRE method instead of custom algorithm --- .../java/com/beust/jcommander/DefaultUsageFormatter.java | 9 ++------- src/main/java/com/beust/jcommander/JCommander.java | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java b/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java index 1a463c3f..2968fd2c 100644 --- a/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java +++ b/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java @@ -404,13 +404,8 @@ public static String getI18nString(ResourceBundle bundle, String key, String def * * @return count-many spaces */ - public static CharSequence s(int count) { - StringBuilder result = new StringBuilder(); - - for (int i = 0; i < count; i++) { - result.append(" "); - } - return result; + public static String s(int count) { + return " ".repeat(count); } /** diff --git a/src/main/java/com/beust/jcommander/JCommander.java b/src/main/java/com/beust/jcommander/JCommander.java index e482d008..4d7e8c06 100644 --- a/src/main/java/com/beust/jcommander/JCommander.java +++ b/src/main/java/com/beust/jcommander/JCommander.java @@ -1566,13 +1566,8 @@ public String getParsedAlias() { /** * @return n spaces */ - private CharSequence s(int count) { - StringBuilder result = new StringBuilder(); - for (int i = 0; i < count; i++) { - result.append(" "); - } - - return result; + private String s(int count) { + return " ".repeat(count); } /**