RouterInfo, RouterAddress: Optimizations and integrity checks

- Remove synchronization
    - Do not allow contents to change after being set, throw IllegalStateException
    - Do not copy contents out in getters
    - Make options final
    - Add getOption() and getOptionsMap() methods
This commit is contained in:
zzz
2011-12-23 21:41:58 +00:00
parent 36cb07b0cc
commit 8fa720539a
13 changed files with 215 additions and 153 deletions

View File

@ -376,9 +376,8 @@ public class NetDbRenderer {
int cost = addr.getCost();
if (!((style.equals("SSU") && cost == 5) || (style.equals("NTCP") && cost == 10)))
buf.append('[').append(_("cost")).append('=').append("" + cost).append("] ");
Properties p = new OrderedProperties();
p.putAll(addr.getOptions());
for (Map.Entry e : p.entrySet()) {
Map p = addr.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
String name = (String) e.getKey();
String val = (String) e.getValue();
buf.append('[').append(_(DataHelper.stripHTML(name))).append('=').append(DataHelper.stripHTML(val)).append("] ");
@ -387,9 +386,10 @@ public class NetDbRenderer {
buf.append("</td></tr>\n");
if (full) {
buf.append("<tr><td>" + _("Stats") + ": <br><code>");
for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
String val = info.getOption(key);
Map p = info.getOptionsMap();
for (Map.Entry e : (Set<Map.Entry>) p.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append(DataHelper.stripHTML(key)).append(" = ").append(DataHelper.stripHTML(val)).append("<br>\n");
}
buf.append("</code></td></tr>\n");
@ -412,7 +412,7 @@ public class NetDbRenderer {
if (style.equals("NTCP")) {
rv |= NTCP;
} else if (style.equals("SSU")) {
if (addr.getOptions().getProperty("iport0") != null)
if (addr.getOption("iport0") != null)
rv |= SSUI;
else
rv |= SSU;