More efficient Txt.repeat

This commit is contained in:
Olof Larsson 2015-03-24 21:58:26 +01:00
parent 7058cdc1c1
commit 687d461d5d

View File

@ -219,8 +219,17 @@ public class Txt
public static String repeat(String string, int times)
{
if (times <= 0) return "";
else return string + repeat(string, times-1);
// Create Ret
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)