[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-bugs] #17824 [metrics-lib]: switch on string instead of many if-else with String comparison
#17824: switch on string instead of many if-else with String comparison
-----------------------------+---------------------
Reporter: iwakeh | Owner: karsten
Type: enhancement | Status: new
Priority: Low | Milestone:
Component: metrics-lib | Version:
Severity: Minor | Keywords:
Actual Points: | Parent ID: #17822
Points: | Sponsor:
-----------------------------+---------------------
example from BridgeNetworkStatusImpl (there are many more and longer
ones):
{{{
switch(keyword){
case "published":
this.parsePublishedLine(line, parts);
case "flag-thresholds":
this.parseFlagThresholdsLine(line, parts);
}
if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '" + line
+ "' in bridge network status.");
} else {
if (this.unrecognizedLines == null) {
this.unrecognizedLines = new ArrayList<String>();
}
...
}}}
instead of
{{{
if (keyword.equals("published")) {
this.parsePublishedLine(line, parts);
} else if (keyword.equals("flag-thresholds")) {
this.parseFlagThresholdsLine(line, parts);
} else if (this.failUnrecognizedDescriptorLines) {
throw new DescriptorParseException("Unrecognized line '" + line
+ "' in bridge network status.");
} else {
if (this.unrecognizedLines == null) {
this.unrecognizedLines = new ArrayList<String>();
}
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/17824>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs