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

[tor-commits] [onionoo/release] Bulk-add elements rather than loop over them.



commit 62e30fc658918a483cf54b4da5e79ee56f692eac
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Mon Aug 20 20:21:36 2018 +0200

    Bulk-add elements rather than loop over them.
---
 .../onionoo/writer/DetailsDocumentWriter.java       | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
index 6519de5..99b4e5d 100644
--- a/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
+++ b/src/main/java/org/torproject/onionoo/writer/DetailsDocumentWriter.java
@@ -120,27 +120,18 @@ public class DetailsDocumentWriter implements DocumentWriter {
     detailsDocument.setPlatform(detailsStatus.getPlatform());
     if (detailsStatus.getAllegedFamily() != null
         && !detailsStatus.getAllegedFamily().isEmpty()) {
-      SortedSet<String> allegedFamily = new TreeSet<>();
-      for (String familyMember : detailsStatus.getAllegedFamily()) {
-        allegedFamily.add(familyMember);
-      }
-      detailsDocument.setAllegedFamily(allegedFamily);
+      detailsDocument.setAllegedFamily(
+          new TreeSet<>(detailsStatus.getAllegedFamily()));
     }
     if (detailsStatus.getEffectiveFamily() != null
         && !detailsStatus.getEffectiveFamily().isEmpty()) {
-      SortedSet<String> effectiveFamily = new TreeSet<>();
-      for (String familyMember : detailsStatus.getEffectiveFamily()) {
-        effectiveFamily.add(familyMember);
-      }
-      detailsDocument.setEffectiveFamily(effectiveFamily);
+      detailsDocument.setEffectiveFamily(
+          new TreeSet<>(detailsStatus.getEffectiveFamily()));
     }
     if (detailsStatus.getIndirectFamily() != null
         && !detailsStatus.getIndirectFamily().isEmpty()) {
-      SortedSet<String> indirectFamily = new TreeSet<>();
-      for (String familyMember : detailsStatus.getIndirectFamily()) {
-        indirectFamily.add(familyMember);
-      }
-      detailsDocument.setIndirectFamily(indirectFamily);
+      detailsDocument.setIndirectFamily(
+          new TreeSet<>(detailsStatus.getIndirectFamily()));
     }
     detailsDocument.setExitPolicyV6Summary(
         detailsStatus.getExitPolicyV6Summary());



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