[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [collector/master] Remove a couple redundant string operations.



commit 00eb709d43499da76bc12fec5702197e1fc7e04a
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Tue Aug 21 12:07:28 2018 +0200

    Remove a couple redundant string operations.
---
 .../metrics/collector/bridgedescs/SanitizedBridgesWriter.java          | 3 +--
 .../torproject/metrics/collector/persist/DescriptorPersistence.java    | 2 +-
 .../metrics/collector/bridgedescs/SanitizedBridgesWriterTest.java      | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
index c5a28d6..d9a0322 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -358,8 +358,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
       byte[] secret = this.getSecretForMonth(month);
       System.arraycopy(secret, 31, hashInput, 36, 19);
       String hashOutput = DigestUtils.sha256Hex(hashInput);
-      sb.append(hashOutput.substring(hashOutput.length() - 6,
-          hashOutput.length() - 4));
+      sb.append(hashOutput, hashOutput.length() - 6, hashOutput.length() - 4);
       sb.append(":");
       sb.append(hashOutput.substring(hashOutput.length() - 4));
     }
diff --git a/src/main/java/org/torproject/metrics/collector/persist/DescriptorPersistence.java b/src/main/java/org/torproject/metrics/collector/persist/DescriptorPersistence.java
index bd24c81..fed4839 100644
--- a/src/main/java/org/torproject/metrics/collector/persist/DescriptorPersistence.java
+++ b/src/main/java/org/torproject/metrics/collector/persist/DescriptorPersistence.java
@@ -43,7 +43,7 @@ public abstract class DescriptorPersistence<T extends Descriptor> {
     if (annotations.isEmpty()) {
       this.annotation = defaultAnnotation;
     } else {
-      StringBuilder sb = new StringBuilder("");
+      StringBuilder sb = new StringBuilder();
       for (String annotation : annotations) {
         sb.append(annotation).append("\n");
       }
diff --git a/src/test/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriterTest.java b/src/test/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriterTest.java
index 819c830..1267d4a 100644
--- a/src/test/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriterTest.java
+++ b/src/test/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriterTest.java
@@ -136,7 +136,7 @@ public class SanitizedBridgesWriterTest {
     this.configuration.setProperty(Key.BridgeLocalOrigins.name(),
         bridgeDirectoriesDir);
     this.configuration.setProperty(Key.OutputPath.name(),
-        sanitizedBridgesDirectory.toFile().getParent().toString());
+        sanitizedBridgesDirectory.toFile().getParent());
   }
 
   /** Runs this test by executing all builders, performing the sanitizing



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits