Revert "Performance pass 5 (String concatenation in loop)"

This reverts commit d9d0f426e443020ab9141b080a08e22c74795d0e.
This commit is contained in:
Andrew 2020-10-15 22:46:05 -07:00 committed by Daniel Mills
parent 1a7d4c2c37
commit 3daf03d89a
5 changed files with 45 additions and 45 deletions

View File

@ -99,17 +99,17 @@ public class IrisDataManager
{ {
File examples = new File(dataFolder, "example"); File examples = new File(dataFolder, "example");
examples.mkdirs(); examples.mkdirs();
StringBuilder biomes = new StringBuilder(); String biomes = "";
StringBuilder envs = new StringBuilder(); String envs = "";
for(Biome i : Biome.values()) for(Biome i : Biome.values())
{ {
biomes.append(i.name()).append("\n"); biomes += i.name() + "\n";
} }
for(Environment i : Environment.values()) for(Environment i : Environment.values())
{ {
envs.append(i.name()).append("\n"); envs += i.name() + "\n";
} }
try try
@ -118,8 +118,8 @@ public class IrisDataManager
new File(examples, "example-pack/biomes").mkdirs(); new File(examples, "example-pack/biomes").mkdirs();
new File(examples, "example-pack/dimensions").mkdirs(); new File(examples, "example-pack/dimensions").mkdirs();
new File(examples, "example-pack/generators").mkdirs(); new File(examples, "example-pack/generators").mkdirs();
IO.writeAll(new File(examples, "biome-list.txt"), biomes.toString()); IO.writeAll(new File(examples, "biome-list.txt"), biomes);
IO.writeAll(new File(examples, "environment-list.txt"), envs.toString()); IO.writeAll(new File(examples, "environment-list.txt"), envs);
IrisGenerator gen = new IrisGenerator(); IrisGenerator gen = new IrisGenerator();
IrisNoiseGenerator n = new IrisNoiseGenerator(); IrisNoiseGenerator n = new IrisNoiseGenerator();

View File

@ -753,7 +753,7 @@ public enum C
*/ */
public static String getLastColors(String input) public static String getLastColors(String input)
{ {
StringBuilder result = new StringBuilder(); String result = "";
int length = input.length(); int length = input.length();
// Search backwards from the end as it is faster // Search backwards from the end as it is faster
@ -767,7 +767,7 @@ public enum C
if(color != null) if(color != null)
{ {
result.insert(0, color.toString()); result = color.toString() + result;
// Once we find a color or reset we can stop searching // Once we find a color or reset we can stop searching
if(color.isColor() || color.equals(RESET)) if(color.isColor() || color.equals(RESET))
@ -778,7 +778,7 @@ public enum C
} }
} }
return result.toString(); return result;
} }
static static

View File

@ -72,24 +72,24 @@ public class Form
*/ */
public static String capitalize(String s) public static String capitalize(String s)
{ {
StringBuilder roll = new StringBuilder(); String roll = "";
boolean f = true; boolean f = true;
for(Character i : s.trim().toCharArray()) for(Character i : s.trim().toCharArray())
{ {
if(f) if(f)
{ {
roll.append(Character.toUpperCase(i)); roll += Character.toUpperCase(i);
f = false; f = false;
} }
else else
{ {
roll.append(i); roll += i;
} }
} }
return roll.toString(); return roll;
} }
/** /**
@ -101,11 +101,11 @@ public class Form
*/ */
public static String capitalizeWords(String s) public static String capitalizeWords(String s)
{ {
StringBuilder rollx = new StringBuilder(); String rollx = "";
for(String i : s.trim().split(" ")) for(String i : s.trim().split(" "))
{ {
rollx.append(" ").append(capitalize(i.trim())); rollx += " " + capitalize(i.trim());
} }
return rollx.substring(1); return rollx.substring(1);
@ -1038,27 +1038,27 @@ public class Form
*/ */
public static String cname(String clazz) public static String cname(String clazz)
{ {
StringBuilder codeName = new StringBuilder(); String codeName = "";
for(Character i : clazz.toCharArray()) for(Character i : clazz.toCharArray())
{ {
if(Character.isUpperCase(i)) if(Character.isUpperCase(i))
{ {
codeName.append("-").append(Character.toLowerCase(i)); codeName = codeName + "-" + Character.toLowerCase(i);
} }
else else
{ {
codeName.append(i); codeName = codeName + i;
} }
} }
if(codeName.toString().startsWith("-")) if(codeName.startsWith("-"))
{ {
codeName = new StringBuilder(codeName.substring(1)); codeName = codeName.substring(1);
} }
return codeName.toString(); return codeName;
} }
/** /**
@ -1439,17 +1439,17 @@ public class Form
roman_numerals.put("IV", 4); roman_numerals.put("IV", 4);
roman_numerals.put("I", 1); roman_numerals.put("I", 1);
StringBuilder res = new StringBuilder(); String res = "";
for(Map.Entry<String, Integer> entry : roman_numerals.entrySet()) for(Map.Entry<String, Integer> entry : roman_numerals.entrySet())
{ {
int matches = num / entry.getValue(); int matches = num / entry.getValue();
res.append(repeat(entry.getKey(), matches)); res += repeat(entry.getKey(), matches);
num = num % entry.getValue(); num = num % entry.getValue();
} }
return res.toString(); return res;
} }
/** /**

View File

@ -407,33 +407,33 @@ public class IO
public static String readAll(File f) throws IOException public static String readAll(File f) throws IOException
{ {
BufferedReader bu = new BufferedReader(new FileReader(f)); BufferedReader bu = new BufferedReader(new FileReader(f));
StringBuilder c = new StringBuilder(); String c = "";
String l = ""; String l = "";
while((l = bu.readLine()) != null) while((l = bu.readLine()) != null)
{ {
c.append(l).append("\n"); c += l + "\n";
} }
bu.close(); bu.close();
return c.toString(); return c;
} }
public static String readAll(InputStream in) throws IOException public static String readAll(InputStream in) throws IOException
{ {
BufferedReader bu = new BufferedReader(new InputStreamReader(in)); BufferedReader bu = new BufferedReader(new InputStreamReader(in));
StringBuilder c = new StringBuilder(); String c = "";
String l = ""; String l = "";
while((l = bu.readLine()) != null) while((l = bu.readLine()) != null)
{ {
c.append(l).append("\n"); c += l + "\n";
} }
bu.close(); bu.close();
return c.toString(); return c;
} }
/** /**

View File

@ -31,28 +31,28 @@ public class Violator
{ {
Constructor<?> co = (Constructor<?>) o; Constructor<?> co = (Constructor<?>) o;
StringBuilder mx = new StringBuilder(); String mx = "";
for(Class<?> i : co.getParameterTypes()) for(Class<?> i : co.getParameterTypes())
{ {
mx.append(",").append(i.getCanonicalName()); mx += "," + i.getCanonicalName();
} }
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); mx = mx.length() >= 1 ? mx.substring(1) : mx;
return id(co.getDeclaringClass(), null) + "(" + mx + ")"; return id(co.getDeclaringClass(), null) + "(" + mx + ")";
} }
if(o instanceof Method) if(o instanceof Method)
{ {
StringBuilder mx = new StringBuilder(); String mx = "";
for(Class<?> i : ((Method) o).getParameterTypes()) for(Class<?> i : ((Method) o).getParameterTypes())
{ {
mx.append(",").append(i.getCanonicalName()); mx += "," + i.getCanonicalName();
} }
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); mx = mx.length() >= 1 ? mx.substring(1) : mx;
return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")"; return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")";
} }
@ -83,14 +83,14 @@ public class Violator
public static Constructor<?> getConstructor(Class<?> c, Class<?>... params) throws NoSuchMethodException, SecurityException public static Constructor<?> getConstructor(Class<?> c, Class<?>... params) throws NoSuchMethodException, SecurityException
{ {
StringBuilder mx = new StringBuilder(); String mx = "";
for(Class<?> i : params) for(Class<?> i : params)
{ {
mx.append(",").append(i.getCanonicalName()); mx += "," + i.getCanonicalName();
} }
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); mx = mx.length() >= 1 ? mx.substring(1) : mx;
if(!h(id(c, null) + "(" + mx + ")")) if(!h(id(c, null) + "(" + mx + ")"))
{ {
@ -159,14 +159,14 @@ public class Violator
public static Method getMethod(Class<?> c, String name, Class<?>... pars) throws Throwable public static Method getMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
{ {
String iv = ""; String iv = "";
StringBuilder mx = new StringBuilder(); String mx = "";
for(Class<?> i : pars) for(Class<?> i : pars)
{ {
mx.append(",").append(i.getCanonicalName()); mx += "," + i.getCanonicalName();
} }
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); mx = mx.length() >= 1 ? mx.substring(1) : mx;
iv = id(c, null) + "." + name + "(" + mx + ")"; iv = id(c, null) + "." + name + "(" + mx + ")";
if(!h(iv)) if(!h(iv))
@ -206,14 +206,14 @@ public class Violator
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... pars) throws Throwable public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
{ {
String iv = ""; String iv = "";
StringBuilder mx = new StringBuilder(); String mx = "";
for(Class<?> i : pars) for(Class<?> i : pars)
{ {
mx.append(",").append(i.getCanonicalName()); mx += "," + i.getCanonicalName();
} }
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString()); mx = mx.length() >= 1 ? mx.substring(1) : mx;
iv = id(c, null) + "." + name + "(" + mx + ")"; iv = id(c, null) + "." + name + "(" + mx + ")";
if(!h(iv)) if(!h(iv))