mirror of
https://github.com/i2p/i2p.i2p.git
synced 2026-04-26 15:17:28 +00:00
Console: Improve writing efficiency
replace out.write(buf.toString) with out.append(buf) to eliminate extra copy and object churn
This commit is contained in:
@@ -77,7 +77,7 @@ class PersistNews {
|
||||
out = new OutputStreamWriter(new GZIPOutputStream(new SecureFileOutputStream(file)), "UTF-8");
|
||||
out.write(XML_START);
|
||||
XMLParser.toString(buf, entry);
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
} catch (IOException ioe) {
|
||||
if (log.shouldWarn())
|
||||
|
||||
@@ -1824,7 +1824,7 @@ public class ConsoleUpdateManager implements UpdateManager, RouterApp {
|
||||
buf.append("<div class=\"debug_container\">");
|
||||
toString(buf, _downloaders);
|
||||
buf.append("</div>");
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
}
|
||||
|
||||
/** debug */
|
||||
|
||||
@@ -39,7 +39,7 @@ class BanlistRenderer {
|
||||
buf.append("<h3 id=\"bannedpeers\">").append(_t("Banned Peers"));
|
||||
if (entries.isEmpty()) {
|
||||
buf.append("</h3><i>").append(_t("none")).append("</i>");
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
return;
|
||||
} else {
|
||||
buf.append(" (").append(entries.size()).append(")</h3>");
|
||||
@@ -81,7 +81,7 @@ class BanlistRenderer {
|
||||
buf.append("</li>\n");
|
||||
}
|
||||
buf.append("</ul>\n");
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ConfigKeyringHelper extends HelperBase {
|
||||
"<input type=\"submit\" name=\"action\" class=\"delete\" value=\"").append(_t("Delete key")).append("\">" +
|
||||
"</td></tr></table>");
|
||||
}
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,6 @@ public class ConfigNavHelper extends HelperBase {
|
||||
}
|
||||
if (!span)
|
||||
buf.append("</center>");
|
||||
_out.write(buf.toString());
|
||||
_out.append(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JobQueueHelper extends HelperBase {
|
||||
}
|
||||
buf.append("</ol>\n");
|
||||
getJobCounts(buf, counter);
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
|
||||
buf.append("<h3 id=\"scheduledjobs\">")
|
||||
@@ -118,14 +118,14 @@ public class JobQueueHelper extends HelperBase {
|
||||
}
|
||||
buf.append("</ol></div>\n");
|
||||
getJobCounts(buf, counter);
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
|
||||
buf.append("<h3 id=\"totaljobstats\">")
|
||||
.append(_t("Total Job Statistics"))
|
||||
.append("</h3>\n");
|
||||
getJobStats(buf);
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
}
|
||||
|
||||
/** @since 0.9.5 */
|
||||
|
||||
@@ -75,7 +75,7 @@ public class OldConsoleHelper extends HelperBase {
|
||||
long free = Runtime.getRuntime().freeMemory()/1024;
|
||||
buf.append("<b>Memory:</b> In use: ").append((tot-free)).append("KB Free: ").append(free).append("KB <br>\n");
|
||||
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,6 @@ public class ProfilesHelper extends HelperBase {
|
||||
if (!span)
|
||||
buf.append("</center>");
|
||||
buf.append("</div>");
|
||||
_out.write(buf.toString());
|
||||
_out.append(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class StatsGenerator {
|
||||
|
||||
buf.append("<form action=\"\"><b>");
|
||||
buf.append(_t("Jump to section")).append(":</b> <select class=\"onchange\">");
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
|
||||
Map<String, SortedSet<String>> unsorted = _context.statManager().getStatsByGroup();
|
||||
@@ -89,14 +89,14 @@ public class StatsGenerator {
|
||||
// buf.append(stat);
|
||||
// buf.append("</option>\n");
|
||||
//}
|
||||
//out.write(buf.toString());
|
||||
//out.append(buf);
|
||||
//buf.setLength(0);
|
||||
}
|
||||
// TODO this is broken for non-js
|
||||
buf.append("</select> <input type=\"submit\" value=\"").append(_t("GO")).append("\" />");
|
||||
buf.append("</form>");
|
||||
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
|
||||
for (Map.Entry<String, Set<String>> entry : groups.entrySet()) {
|
||||
@@ -108,7 +108,7 @@ public class StatsGenerator {
|
||||
buf.append(translateGroup(group));
|
||||
buf.append("</a></h3>");
|
||||
buf.append("<ul class=\"statlist\">");
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
for (String stat : stats) {
|
||||
buf.append("<li class=\"statsName\"><b><a name=\"");
|
||||
@@ -120,7 +120,7 @@ public class StatsGenerator {
|
||||
renderFrequency(stat, buf);
|
||||
else
|
||||
renderRate(stat, buf, showAll);
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
buf.setLength(0);
|
||||
}
|
||||
out.write("</ul><br>\n");
|
||||
|
||||
@@ -138,7 +138,7 @@ class SummaryBarRenderer {
|
||||
|
||||
// Only output section if there's more than the <hr> to print
|
||||
if (buf.length() > 5)
|
||||
out.write(buf.toString());
|
||||
out.append(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user