commit a472d7f3425feec9b9bed552b05af33dab20fee1 Author: Karsten Loesing karsten.loesing@gmx.net Date: Wed May 28 10:11:20 2014 +0200
Store relay flags more efficiently.
Turns out a TreeSet<String> requires more memory than a String[]. We can put together the TreeSet<String> when we need it. --- .../descriptor/impl/NetworkStatusEntryImpl.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java index 19f951e..7bfcb29 100644 --- a/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java +++ b/src/org/torproject/descriptor/impl/NetworkStatusEntryImpl.java @@ -138,10 +138,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { private void parseSLine(String line, String[] parts) throws DescriptorParseException { this.parsedAtMostOnceKeyword("s"); - this.flags = new TreeSet<String>(); - for (int i = 1; i < parts.length; i++) { - this.flags.add(parts[i]); - } + this.flags = parts; }
private void parseVLine(String line, String[] parts) @@ -267,9 +264,15 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry { return new ArrayList<String>(this.orAddresses); }
- private SortedSet<String> flags; + private String[] flags; public SortedSet<String> getFlags() { - return new TreeSet<String>(this.flags); + SortedSet<String> result = new TreeSet<String>(); + if (this.flags != null) { + for (int i = 1; i < this.flags.length; i++) { + result.add(this.flags[i]); + } + } + return result; }
private String version;
tor-commits@lists.torproject.org