Skip to content

Commit

Permalink
Performance pass #4 (Concatenation)
Browse files Browse the repository at this point in the history
Took 6 minutes
  • Loading branch information
Andrew committed Sep 12, 2020
1 parent 56ac439 commit 8781b93
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 134 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/volmit/react/action/ActionDump.java
Expand Up @@ -158,18 +158,18 @@ public void run()

private String readFile(File file) throws IOException, ParseException, org.json.simple.parser.ParseException
{
String c = "";
StringBuilder c = new StringBuilder();
String l = "";
BufferedReader bu = new BufferedReader(new FileReader(file));

while((l = bu.readLine()) != null)
{
c += l + "\n";
c.append(l).append("\n");
}

bu.close();

return Paste.paste(c) + "." + file.getName().split("\\.")[file.getName().split("\\.").length - 1];
return Paste.paste(c.toString()) + "." + file.getName().split("\\.")[file.getName().split("\\.").length - 1];
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/volmit/react/api/CubicleIterator.java
Expand Up @@ -133,14 +133,14 @@ public void print()
{
for(int i = 0; i < yCubes; i++)
{
String k = "";
StringBuilder k = new StringBuilder();

for(int j = 0; j < xCubes; j++)
{
k += "[" + positionFor(mapping[i][j]) + "] ";
k.append("[").append(positionFor(mapping[i][j])).append("] ");
}

D.v(k);
D.v(k.toString());
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/volmit/react/api/MonitorHeading.java
Expand Up @@ -43,17 +43,17 @@ public String getHeadText()

public String getChildText()
{
String m = "";
StringBuilder m = new StringBuilder();

for(ISampler i : getChildren())
{
String p = i.getColor() + i.get() + C.RESET + i.getColor() + " " + i.getID();
m += " " + p;
m.append(" ").append(p);
}

if(m.length() < 2)
{
return m;
return m.toString();
}

return m.substring(1);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/volmit/react/api/RecordBook.java
Expand Up @@ -204,14 +204,14 @@ private void read() throws IOException
FileReader fin = new FileReader(recordFile);
BufferedReader bu = new BufferedReader(fin);
String line;
String content = "";
StringBuilder content = new StringBuilder();

while((line = bu.readLine()) != null)
{
content += line;
content.append(line);
}

bu.close();
js = new JSONObject(content);
js = new JSONObject(content.toString());
}
}
20 changes: 10 additions & 10 deletions src/main/java/com/volmit/react/api/TitleMonitor.java
Expand Up @@ -57,52 +57,52 @@ public MonitorHeading getHeadFor(int sel)

public String getHotbarHeadFor(int sel, boolean b, MonitorController mc, ReactPlayer rp, int cd)
{
String m = "";
StringBuilder m = new StringBuilder();

if(!b)
{
return m;
return m.toString();
}

for(ISampler i : getHeadFor(sel).getChildren())
{
String cx = mc.prefixForSub(rp, i.getColor(), cd);
m += " " + C.RESET + cx + "" + C.stripColor(i.get());
m.append(" " + C.RESET).append(cx).append(C.stripColor(i.get()));
}

if(m.length() < 2)
{
return m;
return m.toString();
}

return m.substring(1);
}

public String getHotbarFor(int sel, boolean b, ReactPlayer rp)
{
String m = "";
StringBuilder m = new StringBuilder();
int sl = 0;

for(MonitorHeading i : headings)
{
String pd = C.DARK_GRAY.toString();
String po = i.getHead().getColor().toString();
String pc = (sel == -1 || sl == sel) ? po : pd;
m += " " + C.RESET + pc + i.getHead().get();
m.append(" " + C.RESET).append(pc).append(i.getHead().get());
sl++;
}

if(m.length() < 2)
{
return m;
return m.toString();
}

return m.substring(1);
}

public String getConsoleHotbar()
{
String m = "";
StringBuilder m = new StringBuilder();
int sl = 0;
int sel = -1;

Expand All @@ -111,13 +111,13 @@ public String getConsoleHotbar()
String pd = C.DARK_GRAY.toString();
String po = i.getHead().getColor().toString();
String pc = (sel == -1 || sl == sel) ? po : pd;
m += " " + C.RESET + pc + i.getHead().get();
m.append(" " + C.RESET).append(pc).append(i.getHead().get());
sl++;
}

if(m.length() < 2)
{
return m;
return m.toString();
}

return m.substring(1);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/volmit/react/command/CommandStatus.java
Expand Up @@ -67,8 +67,8 @@ private ItemStack makeBook() {
}

private void addSpikePages(GList<String> set) {
String f = ""; //$NON-NLS-1$
f += C.DARK_AQUA + C.BOLD.toString() + C.ITALIC + Lang.getString("command.status.server-spikes") + C.RESET; //$NON-NLS-1$
StringBuilder f = new StringBuilder(); //$NON-NLS-1$
f.append(C.DARK_AQUA).append(C.BOLD.toString()).append(C.ITALIC).append(Lang.getString("command.status.server-spikes")).append(C.RESET); //$NON-NLS-1$

GList<Integer> ints = React.instance.spikeController.getSpikes().v();
Collections.sort(ints);
Expand All @@ -82,13 +82,13 @@ private void addSpikePages(GList<String> set) {
for (String j : React.instance.spikeController.getSpikes().k()) {
if (React.instance.spikeController.getSpikes().get(j).equals(i)) {
String jn = j.length() > 14 ? j.substring(0, 14) + Lang.getString("command.status.elips") : j; //$NON-NLS-1$
f += C.GRAY + jn + ": " + C.BLACK + C.BOLD.toString() + i + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
f.append(C.GRAY).append(jn).append(": ").append(C.BLACK).append(C.BOLD.toString()).append(i).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$
break;
}
}
}

set.add(f);
set.add(f.toString());
}

private void addStatusPages(GList<String> set) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/volmit/react/command/CommandSubscribe.java
Expand Up @@ -29,11 +29,11 @@ public CommandSubscribe()
description = Info.COMMAND_SUB_DESCRIPTION;
sideGate = SideGate.PLAYERS_ONLY;

String ch = "Channels: ";
StringBuilder ch = new StringBuilder("Channels: ");

for(Note i : Note.values())
{
ch += C.WHITE + i.toString().toLowerCase() + ", ";
ch.append(C.WHITE).append(i.toString().toLowerCase()).append(", ");
}

registerParameterDescription("[channel]", "The channel to subscribe to. " + ch + C.GRAY);
Expand Down
Expand Up @@ -289,14 +289,14 @@ public void tick()
cts.put(j, cts.get(j) + 1);
}

String s = C.WHITE + i + C.GRAY + " ran";
StringBuilder s = new StringBuilder(C.WHITE + i + C.GRAY + " ran");

for(ActionType j : cts.k())
{
s += " " + (cts.get(j) > 1 ? (C.GRAY.toString() + cts.get(j) + "x " + C.WHITE) : C.WHITE + "") + j.getName() + C.GRAY;
s.append(" ").append(cts.get(j) > 1 ? (C.GRAY.toString() + cts.get(j) + "x " + C.WHITE) : C.WHITE + "").append(j.getName()).append(C.GRAY);
}

Note.ACTION.bake(s);
Note.ACTION.bake(s.toString());
}

rans.clear();
Expand Down
Expand Up @@ -271,18 +271,18 @@ public String trim(String cls)
return cls;
}

String m = "";
StringBuilder m = new StringBuilder();
GList<String> v = new GList<String>(cls.split("\\."));
String l = v.popLast();

for(String i : v)
{
m += i.charAt(0) + ".";
m.append(i.charAt(0)).append(".");
}

m += l;
m.append(l);

return m;
return m.toString();
}

public String fcf(String className)
Expand Down
Expand Up @@ -91,17 +91,17 @@ public void run()
{
if(dlf.exists())
{
String cf = "";
StringBuilder cf = new StringBuilder();
BufferedReader bu = new BufferedReader(new FileReader(dlf));
String ln = "";

while((ln = bu.readLine()) != null)
{
cf += ln;
cf.append(ln);
}

bu.close();
JSONObject jso = new JSONObject(cf);
JSONObject jso = new JSONObject(cf.toString());
oldVersion = jso.getInt("version");
}

Expand Down Expand Up @@ -152,17 +152,17 @@ public void onDownloadFailed(Download download)

private void downloadAll(boolean b) throws IOException
{
String cf = "";
StringBuilder cf = new StringBuilder();
BufferedReader bu = new BufferedReader(new FileReader(dlf));
String ln = "";

while((ln = bu.readLine()) != null)
{
cf += ln;
cf.append(ln);
}

bu.close();
JSONObject jso = new JSONObject(cf);
JSONObject jso = new JSONObject(cf.toString());

boolean ud = false;

Expand Down Expand Up @@ -240,17 +240,17 @@ private void check()
{
try
{
String cf = "";
StringBuilder cf = new StringBuilder();
BufferedReader bu = new BufferedReader(new FileReader(dlf));
String ln = "";

while((ln = bu.readLine()) != null)
{
cf += ln;
cf.append(ln);
}

bu.close();
JSONObject jso = new JSONObject(cf);
JSONObject jso = new JSONObject(cf.toString());
int newVersion = jso.getInt("version");

if(newVersion != oldVersion)
Expand Down
Expand Up @@ -247,15 +247,15 @@ public void constructMonitor()
try
{
BufferedReader bu = new BufferedReader(new FileReader(mf));
String c = "";
StringBuilder c = new StringBuilder();
String l = "";

while((l = bu.readLine()) != null)
{
c += l + "\n";
c.append(l).append("\n");
}

JSONArray jo = new JSONArray(c);
JSONArray jo = new JSONArray(c.toString());
TitleCollection tm = new TitleCollection(jo);

for(TitleHeader i : tm.getHeaders())
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/volmit/react/util/CPS.java
Expand Up @@ -119,17 +119,17 @@ private static String readResource(File f, String resource) throws IOException
InputStream stream = zipFile.getInputStream(entry);
InputStreamReader reads = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(reads);
String src = "";
StringBuilder src = new StringBuilder();
String line;

while((line = reader.readLine()) != null)
{
src = src + line + "\n";
src.append(line).append("\n");
}

reader.close();

return src;
return src.toString();
}
}

Expand Down

0 comments on commit 8781b93

Please sign in to comment.