More efficient Txt.repeat
This commit is contained in:
parent
7058cdc1c1
commit
687d461d5d
@ -219,8 +219,17 @@ public class Txt
|
|||||||
|
|
||||||
public static String repeat(String string, int times)
|
public static String repeat(String string, int times)
|
||||||
{
|
{
|
||||||
if (times <= 0) return "";
|
// Create Ret
|
||||||
else return string + repeat(string, times-1);
|
StringBuilder ret = new StringBuilder(times);
|
||||||
|
|
||||||
|
// Fill Ret
|
||||||
|
for (int i = 0; i < times; i++)
|
||||||
|
{
|
||||||
|
ret.append(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return Ret
|
||||||
|
return ret.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String implode(final Object[] list, final String glue, final String format)
|
public static String implode(final Object[] list, final String glue, final String format)
|
||||||
|
Loading…
Reference in New Issue
Block a user