Clear sets used to validate at-most-once/exactly-once keywords.

Related to 5caa384.  Similarly, keeping these sets around just wastes heap
space.
This commit is contained in:
Karsten Loesing 2014-06-17 20:32:55 +02:00
parent c439d346b9
commit f3a170fb74
3 changed files with 12 additions and 4 deletions

View File

@ -33,7 +33,7 @@ public class DirSourceEntryImpl implements DirSourceEntry {
failUnrecognizedDescriptorLines;
this.initializeKeywords();
this.parseDirSourceEntryBytes();
this.checkKeywords();
this.checkAndClearKeywords();
}
private SortedSet<String> exactlyOnceKeywords, atMostOnceKeywords;
@ -63,11 +63,13 @@ public class DirSourceEntryImpl implements DirSourceEntry {
this.atMostOnceKeywords.remove(keyword);
}
private void checkKeywords() throws DescriptorParseException {
private void checkAndClearKeywords() throws DescriptorParseException {
if (!this.exactlyOnceKeywords.isEmpty()) {
throw new DescriptorParseException("dir-source does not contain a '"
+ this.exactlyOnceKeywords.first() + "' line.");
}
this.exactlyOnceKeywords = null;
this.atMostOnceKeywords = null;
}
private void parseDirSourceEntryBytes()

View File

@ -33,7 +33,7 @@ public class ExitListEntryImpl implements ExitListEntry {
failUnrecognizedDescriptorLines;
this.initializeKeywords();
this.parseExitListEntryBytes();
this.checkKeywords();
this.checkAndClearKeywords();
}
private SortedSet<String> exactlyOnceKeywords;
@ -54,11 +54,12 @@ public class ExitListEntryImpl implements ExitListEntry {
this.exactlyOnceKeywords.remove(keyword);
}
private void checkKeywords() throws DescriptorParseException {
private void checkAndClearKeywords() throws DescriptorParseException {
for (String missingKeyword : this.exactlyOnceKeywords) {
throw new DescriptorParseException("Missing '" + missingKeyword
+ "' line in exit list entry.");
}
this.exactlyOnceKeywords = null;
}
private void parseExitListEntryBytes()

View File

@ -39,6 +39,7 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
failUnrecognizedDescriptorLines;
this.initializeKeywords();
this.parseStatusEntryBytes();
this.clearAtMostOnceKeywords();
}
private SortedSet<String> atMostOnceKeywords;
@ -218,6 +219,10 @@ public class NetworkStatusEntryImpl implements NetworkStatusEntry {
}
}
private void clearAtMostOnceKeywords() {
this.atMostOnceKeywords = null;
}
private String nickname;
public String getNickname() {
return this.nickname;