Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 15 May 2017 06:43:41 +0000 (08:43 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 15 May 2017 06:43:41 +0000 (08:43 +0200)
examples/java/app/bittorrent/Peer.java
examples/java/dht/kademlia/Answer.java
examples/java/dht/kademlia/RoutingTable.java

index 0bdc770..3a2e19e 100644 (file)
@@ -624,10 +624,9 @@ public class Peer extends Process {
   }
 
   private String getStatus() {
   }
 
   private String getStatus() {
-    String s = "";
-    for (int i = 0; i < Common.FILE_PIECES; i++) {
-      s = s + bitfield[i];
-    }
-    return s;
+    StringBuilder s = new StringBuilder("");
+    for (int i = 0; i < Common.FILE_PIECES; i++)
+      s.append(bitfield[i]);
+    return s.toString();
   }
 }
   }
 }
index 1421529..a18bc2a 100644 (file)
@@ -16,7 +16,7 @@ public class Answer {
 
   public Answer(int destinationId) {
     this.destinationId = destinationId;
 
   public Answer(int destinationId) {
     this.destinationId = destinationId;
-    nodes = new ArrayList<Contact>();
+    nodes = new ArrayList<>();
   }
 
   int getDestinationId() {
   }
 
   int getDestinationId() {
index 9dc08f8..c5f88b2 100644 (file)
@@ -18,7 +18,7 @@ public class RoutingTable {
 
   public RoutingTable(int id) {
     this.id = id;
 
   public RoutingTable(int id) {
     this.id = id;
-    buckets = new Vector<Bucket>();
+    buckets = new Vector<>();
     for (int i = 0; i < Common.IDENTIFIER_SIZE + 1; i++) {
       buckets.add(new Bucket(i));
     }
     for (int i = 0; i < Common.IDENTIFIER_SIZE + 1; i++) {
       buckets.add(new Bucket(i));
     }
@@ -102,12 +102,12 @@ public class RoutingTable {
 
   @Override
   public String toString() {
 
   @Override
   public String toString() {
-    String string = "RoutingTable [ id=" + id + " " ;
+    StringBuilder string = new StringBuilder("RoutingTable [ id=" + id + " ");
     for (int i = 0; i < buckets.size(); i++) {
       if (buckets.get(i).size() > 0) {
     for (int i = 0; i < buckets.size(); i++) {
       if (buckets.get(i).size() > 0) {
-        string += buckets.get(i) + " ";
+        string.append(buckets.get(i) + " ");
       }
     }
       }
     }
-    return string;
+    return string.toString();
   }
 }
   }
 }