Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid needless loop.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 6 Feb 2020 08:34:30 +0000 (09:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 6 Feb 2020 08:35:22 +0000 (09:35 +0100)
teshsuite/simdag/evaluate-get-route-time/evaluate-get-route-time.c

index d0dcfa9..ff86f3a 100644 (file)
@@ -28,10 +28,12 @@ int main(int argc, char **argv)
   /* Random number initialization */
   srand( (int) (xbt_os_time()*1000) );
 
-  do {
-    i = rand()%host_count;
-    j = rand()%host_count;
-  } while(i==j);
+  /* Take random i and j, with i != j */
+  xbt_assert(host_count > 1);
+  i = rand() % host_count;
+  j = rand() % (host_count - 1);
+  if (j >= i)
+    j++;
 
   const_sg_host_t h1 = hosts[i];
   const_sg_host_t h2 = hosts[j];