Skip to content

Commit 96c28af

Browse files
author
Vincent Potucek
committed
Can be replaced with 'String.repeat()'
1 parent a0ac600 commit 96c28af

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

lib/src/main/java/com/diffplug/spotless/generic/IndentStep.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,10 @@ String format(String raw) {
104104
if (numSpaces > 0) {
105105
switch (state.type) {
106106
case SPACE:
107-
for (int i = 0; i < numSpaces; i++) {
108-
builder.append(' ');
109-
}
107+
builder.append(" ".repeat(numSpaces));
110108
break;
111109
case TAB:
112-
for (int i = 0; i < numSpaces / state.numSpacesPerTab; i++) {
113-
builder.append('\t');
114-
}
110+
builder.append("\t".repeat(numSpaces / state.numSpacesPerTab));
115111
if (mightBeMultiLineComment && (numSpaces % state.numSpacesPerTab == 1)) {
116112
builder.append(' ');
117113
}

lib/src/main/java/com/diffplug/spotless/sql/dbeaver/DBeaverSQLFormatterConfiguration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ public DBeaverSQLFormatterConfiguration(Properties properties) {
6767
private String getIndentString(String indentType, int indentSize) {
6868
char indentChar = "space".equals(indentType) ? ' ' : '\t';
6969
StringBuilder stringBuilder = new StringBuilder();
70-
for (int i = 0; i < indentSize; i++) {
71-
stringBuilder.append(indentChar);
72-
}
70+
stringBuilder.append(String.valueOf(indentChar).repeat(indentSize));
7371
return stringBuilder.toString();
7472
}
7573

lib/src/main/java/com/diffplug/spotless/sql/dbeaver/SQLTokenizedFormatter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ private int insertReturnAndIndent(final List<FormatterToken> argList, final int
399399
try {
400400
final String defaultLineSeparator = getDefaultLineSeparator();
401401
StringBuilder s = new StringBuilder(defaultLineSeparator);
402-
for (int index = 0; index < argIndent; index++) {
403-
s.append(formatterCfg.getIndentString());
404-
}
402+
s.append(String.valueOf(formatterCfg.getIndentString()).repeat(argIndent));
405403
if (argIndex > 0) {
406404
final FormatterToken token = argList.get(argIndex);
407405
final FormatterToken prevToken = argList.get(argIndex - 1);

0 commit comments

Comments
 (0)