Revert "Merge pull request #15 from cyberpwnn/performance-passes"

This reverts commit e530e30878e39cd08f760b7d7e13ba49836433e1.
This commit is contained in:
Dan 2020-10-16 01:57:47 -04:00 committed by Daniel Mills
parent e530e30878
commit 1a7aa1218a
23 changed files with 97 additions and 91 deletions

View File

@ -36,9 +36,9 @@ public class CommandIrisDownload extends MortarCommand
for(String i : args)
{
if (i.equals("-t") || i.equals("--trim")) {
if(i.equals("-t") || i.equals("--trim"))
{
trim = true;
break;
}
}

View File

@ -48,9 +48,9 @@ public class CommandIrisObjectPaste extends MortarCommand
for(String i : args)
{
if (i.equalsIgnoreCase("-edit")) {
if(i.equalsIgnoreCase("-edit"))
{
intoWand = true;
break;
}
}

View File

@ -51,9 +51,9 @@ public class CommandIrisObjectSave extends MortarCommand
for(String i : args)
{
if (i.equals("-o")) {
if(i.equals("-o"))
{
overwrite = true;
break;
}
}

View File

@ -39,9 +39,9 @@ public class CommandIrisStructureCreate extends MortarCommand
for(String i : args)
{
if (i.equalsIgnoreCase("-3d")) {
if(i.equalsIgnoreCase("-3d"))
{
d3 = true;
break;
}
}

View File

@ -74,9 +74,9 @@ public class CommandIrisStudioGoto extends MortarCommand
for(String i : args)
{
if (i.equalsIgnoreCase("-cave")) {
if(i.equalsIgnoreCase("-cave"))
{
cave = true;
break;
}
}

View File

@ -38,9 +38,9 @@ public class CommandIrisStudioPackage extends MortarCommand
for(String i : args)
{
if (i.equalsIgnoreCase("-o")) {
if(i.equalsIgnoreCase("-o"))
{
o = true;
break;
}
}

View File

@ -298,7 +298,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
NoiseExplorer nv = new NoiseExplorer();
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
KList<String> li = new KList<NoiseStyle>(NoiseStyle.values()).toStringList();
combo = new JComboBox<String>(li.toArray(new String[0]));
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
combo.setSelectedItem("STATIC");
combo.setFocusable(false);
combo.addActionListener(new ActionListener()

View File

@ -47,7 +47,7 @@ public class MythicMobsLink
}
}
return v.toArray(new String[0]);
return v.toArray(new String[v.size()]);
}
public Plugin getMythicMobs()

View File

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

View File

@ -133,7 +133,7 @@ public class B
}
}
return bt.toArray(new String[0]);
return bt.toArray(new String[bt.size()]);
}
public static String[] getItemTypes()
@ -146,7 +146,7 @@ public class B
bt.add(v);
}
return bt.toArray(new String[0]);
return bt.toArray(new String[bt.size()]);
}
public static BlockData getBlockData(String bdxf, IrisDimension resolver)

View File

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

View File

@ -72,9 +72,9 @@ public final class CompoundTag extends Tag {
append = "(\"" + this.getName() + "\")";
}
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n");
bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n");
for (Map.Entry<String, Tag> entry : value.entrySet()) {
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n");
}
bldr.append("}");
return bldr.toString();

View File

@ -5,7 +5,10 @@ public class DoubleArrayUtils
{
public static void shiftRight(double[] values, double push)
{
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);
for(int index = values.length - 2; index >= 0; index--)
{
values[index + 1] = values[index];
}
values[0] = push;
}

View File

@ -72,24 +72,24 @@ public class Form
*/
public static String capitalize(String s)
{
StringBuilder roll = new StringBuilder();
String roll = "";
boolean f = true;
for(Character i : s.trim().toCharArray())
{
if(f)
{
roll.append(Character.toUpperCase(i));
roll += Character.toUpperCase(i);
f = false;
}
else
{
roll.append(i);
roll += i;
}
}
return roll.toString();
return roll;
}
/**
@ -101,11 +101,11 @@ public class Form
*/
public static String capitalizeWords(String s)
{
StringBuilder rollx = new StringBuilder();
String rollx = "";
for(String i : s.trim().split(" "))
{
rollx.append(" ").append(capitalize(i.trim()));
rollx += " " + capitalize(i.trim());
}
return rollx.substring(1);
@ -876,7 +876,7 @@ public class Form
*/
public static String ofSize(long s, int div)
{
double d = (double) s;
Double d = (double) s;
String sub = "Bytes";
if(d > div - 1)
@ -929,7 +929,7 @@ public class Form
*/
public static String ofSize(long s, int div, int dec)
{
double d = (double) s;
Double d = (double) s;
String sub = "Bytes";
if(d > div - 1)
@ -979,7 +979,7 @@ public class Form
{
s = -s;
}
double d = (double) s;
Double d = (double) s;
String sub = "Grams";
if(d > div - 1)
@ -1038,27 +1038,27 @@ public class Form
*/
public static String cname(String clazz)
{
StringBuilder codeName = new StringBuilder();
String codeName = "";
for(Character i : clazz.toCharArray())
{
if(Character.isUpperCase(i))
{
codeName.append("-").append(Character.toLowerCase(i));
codeName = codeName + "-" + Character.toLowerCase(i);
}
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("I", 1);
StringBuilder res = new StringBuilder();
String res = "";
for(Map.Entry<String, Integer> entry : roman_numerals.entrySet())
{
int matches = num / entry.getValue();
res.append(repeat(entry.getKey(), matches));
res += repeat(entry.getKey(), matches);
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
{
BufferedReader bu = new BufferedReader(new FileReader(f));
StringBuilder c = new StringBuilder();
String c = "";
String l = "";
while((l = bu.readLine()) != null)
{
c.append(l).append("\n");
c += l + "\n";
}
bu.close();
return c.toString();
return c;
}
public static String readAll(InputStream in) throws IOException
{
BufferedReader bu = new BufferedReader(new InputStreamReader(in));
StringBuilder c = new StringBuilder();
String c = "";
String l = "";
while((l = bu.readLine()) != null)
{
c.append(l).append("\n");
c += l + "\n";
}
bu.close();
return c.toString();
return c;
}
/**

View File

@ -1652,7 +1652,7 @@ public class JSONObject
*/
public static Object stringToValue(String string)
{
double d;
Double d;
if(string.equals(""))
{
return string;
@ -1682,8 +1682,8 @@ public class JSONObject
{
if(string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1)
{
d = Double.parseDouble(string);
if(!Double.isInfinite(d) && !Double.isNaN(d))
d = Double.valueOf(string);
if(!d.isInfinite() && !d.isNaN())
{
return d;
}

View File

@ -253,7 +253,7 @@ public class KList<T> extends ArrayList<T> implements List<T>
for(String i : toStringList())
{
b.append(split).append(i);
b.append(split + i);
}
return b.toString().substring(split.length());
@ -382,7 +382,10 @@ public class KList<T> extends ArrayList<T> implements List<T>
@SuppressWarnings("unchecked")
public KList<T> add(T... t)
{
Collections.addAll(super, t);
for(T i : t)
{
super.add(i);
}
return this;
}

View File

@ -88,9 +88,9 @@ public final class ListTag extends Tag {
append = "(\"" + this.getName() + "\")";
}
StringBuilder bldr = new StringBuilder();
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
bldr.append("TAG_List" + append + ": " + value.size() + " entries of type " + NBTUtils.getTypeName(type) + "\r\n{\r\n");
for (Tag t : value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") + "\r\n");
}
bldr.append("}");
return bldr.toString();

View File

@ -153,7 +153,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
possibleKeys = v.toArray(new String[v.size()]);
return possibleKeys;
}
@ -201,7 +201,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
possibleKeys = v.toArray(new String[v.size()]);
return possibleKeys;
}

View File

@ -79,7 +79,7 @@ public class ResourceLoader<T extends IrisRegistrant>
}
KList<String> v = new KList<>(m);
preferredKeys = v.toArray(new String[0]);
preferredKeys = v.toArray(new String[v.size()]);
return preferredKeys;
}
@ -116,7 +116,7 @@ public class ResourceLoader<T extends IrisRegistrant>
}
KList<String> v = new KList<>(m);
possibleKeys = v.toArray(new String[0]);
possibleKeys = v.toArray(new String[v.size()]);
return possibleKeys;
}

View File

@ -117,7 +117,7 @@ public class V
try
{
return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class<?>[0])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class<?>[0]))).invoke(o, parameters);
return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class<?>[par.size()])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class<?>[par.size()]))).invoke(o, parameters);
}
catch(Throwable e)

View File

@ -31,28 +31,28 @@ public class Violator
{
Constructor<?> co = (Constructor<?>) o;
StringBuilder mx = new StringBuilder();
String mx = "";
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 + ")";
}
if(o instanceof Method)
{
StringBuilder mx = new StringBuilder();
String mx = "";
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 + ")";
}
@ -83,14 +83,14 @@ public class Violator
public static Constructor<?> getConstructor(Class<?> c, Class<?>... params) throws NoSuchMethodException, SecurityException
{
StringBuilder mx = new StringBuilder();
String mx = "";
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 + ")"))
{
@ -159,14 +159,14 @@ public class Violator
public static Method getMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
{
String iv = "";
StringBuilder mx = new StringBuilder();
String mx = "";
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 + ")";
if(!h(iv))
@ -191,7 +191,7 @@ public class Violator
try
{
Constructor<?> co = getConstructor(c, cv.toArray(new Class<?>[0]));
Constructor<?> co = getConstructor(c, cv.toArray(new Class<?>[cv.size()]));
return (T) co.newInstance(parameters);
}
@ -206,14 +206,14 @@ public class Violator
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
{
String iv = "";
StringBuilder mx = new StringBuilder();
String mx = "";
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 + ")";
if(!h(iv))

View File

@ -115,7 +115,7 @@ public class VirtualCommand
return true;
}
return command.handle(vs, chain.toArray(new String[0]));
return command.handle(vs, chain.toArray(new String[chain.size()]));
}
private boolean checkPermissions(CommandSender sender, ICommand command2)