Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use bit shift operator (FIXME--).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 24 Apr 2019 20:17:30 +0000 (22:17 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 24 Apr 2019 20:19:46 +0000 (22:19 +0200)
examples/deprecated/java/dht/chord/Node.java

index e201df9..9d4ab36 100644 (file)
@@ -305,13 +305,12 @@ public class Node extends Process {
   // It refreshes the finger table of the current node.
   private void fixFingers() {
     Msg.debug("Fixing fingers");
-    int i = this.nextFingerToFix;
-    int successorId = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW
+    int successorId = findSuccessor(id + (1 << nextFingerToFix));
     if (successorId != -1) {
-      if (successorId != fingers[i]) {
-        setFinger(i, successorId);
+      if (successorId != fingers[nextFingerToFix]) {
+        setFinger(nextFingerToFix, successorId);
       }
-      nextFingerToFix = (i + 1) % Common.NB_BITS;
+      nextFingerToFix = (nextFingerToFix + 1) % Common.NB_BITS;
     }
   }