Skip to content

Commit 23df383

Browse files
committed
Simplified the createPadding() method
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@961361 13f79535-47bb-0310-9956-ffa450edef68
1 parent dd1fd38 commit 23df383

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

src/main/java/org/apache/commons/cli/HelpFormatter.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.PrintWriter;
2121
import java.util.ArrayList;
22+
import java.util.Arrays;
2223
import java.util.Collection;
2324
import java.util.Collections;
2425
import java.util.Comparator;
@@ -860,8 +861,7 @@ protected StringBuffer renderWrappedText(StringBuffer sb, int width,
860861
nextLineTabStop = 1;
861862
}
862863

863-
// all following lines must be padded with nextLineTabStop space
864-
// characters
864+
// all following lines must be padded with nextLineTabStop space characters
865865
final String padding = createPadding(nextLineTabStop);
866866

867867
while (true)
@@ -888,7 +888,7 @@ protected StringBuffer renderWrappedText(StringBuffer sb, int width,
888888
/**
889889
* Finds the next text wrap position after <code>startPos</code> for the
890890
* text in <code>text</code> with the column width <code>width</code>.
891-
* The wrap point is the last postion before startPos+width having a
891+
* The wrap point is the last position before startPos+width having a
892892
* whitespace character (space, \n, \r).
893893
*
894894
* @param text The text being searched for the wrap position
@@ -953,14 +953,10 @@ else if (startPos + width >= text.length())
953953
*/
954954
protected String createPadding(int len)
955955
{
956-
StringBuffer sb = new StringBuffer(len);
957-
958-
for (int i = 0; i < len; ++i)
959-
{
960-
sb.append(' ');
961-
}
962-
963-
return sb.toString();
956+
char[] padding = new char[len];
957+
Arrays.fill(padding, ' ');
958+
959+
return new String(padding);
964960
}
965961

966962
/**

0 commit comments

Comments
 (0)