[tor-bugs] #19607 [Metrics/metrics-lib]: avoid repeated keyword strings

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon May 22 09:06:50 UTC 2017


#19607: avoid repeated keyword strings
---------------------------------+-----------------------------------
 Reporter:  iwakeh               |          Owner:  iwakeh
     Type:  enhancement          |         Status:  needs_review
 Priority:  Medium               |      Milestone:  metrics-lib 1.8.0
Component:  Metrics/metrics-lib  |        Version:
 Severity:  Normal               |     Resolution:
 Keywords:                       |  Actual Points:
Parent ID:                       |         Points:
 Reviewer:                       |        Sponsor:
---------------------------------+-----------------------------------

Comment (by karsten):

 Looks good!

 I fixed a tiny bug where a space character got lost:

 {{{
 @@ -66,8 +66,8 @@ public class RelayNetworkStatusConsensusImpl extends
 NetworkStatusImpl
    private void calculateDigest() throws DescriptorParseException {
      try {
        String ascii = new String(this.getRawDescriptorBytes(), "US-
 ASCII");
 -      String startToken = "network-status-version ";
 -      String sigToken = "\ndirectory-signature ";
 +      String startToken = Key.NETWORK_STATUS_VERSION.keyword;
 +      String sigToken = "\ndirectory_signature ";
        if (!ascii.contains(sigToken)) {
          return;
        }
 }}}

 And I added two more commits in an attempt to make it look even better and
 possibly even save memory by storing everything in `EnumSet<Key>` rather
 than `Set<String>`.  Please review
 [https://gitweb.torproject.org/user/karsten/metrics-
 lib.git/log/?h=task-19607-3 my branch task-19607-3] carefully!

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/19607#comment:17>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list