Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid unnecessary loop.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 22 Mar 2012 07:26:22 +0000 (08:26 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 22 Mar 2012 13:16:51 +0000 (14:16 +0100)
src/xbt/log.c

index 23c908b..0e78015 100644 (file)
@@ -547,7 +547,7 @@ void xbt_log_init(int *argc, char **argv)
   //    _XBT_LOGV(log).threshold = xbt_log_priority_debug; /* uncomment to set the LOG category to debug directly */
 
   /* Set logs and init log submodule */
   //    _XBT_LOGV(log).threshold = xbt_log_priority_debug; /* uncomment to set the LOG category to debug directly */
 
   /* Set logs and init log submodule */
-  for (i = 1; i < *argc; i++) {
+  for (j = i = 1; i < *argc; i++) {
     if (!strncmp(argv[i], "--log=", strlen("--log=")) ||
         !strncmp(argv[i], "--gras-log=", strlen("--gras-log=")) ||
         !strncmp(argv[i], "--surf-log=", strlen("--surf-log=")) ||
     if (!strncmp(argv[i], "--log=", strlen("--log=")) ||
         !strncmp(argv[i], "--gras-log=", strlen("--gras-log=")) ||
         !strncmp(argv[i], "--surf-log=", strlen("--surf-log=")) ||
@@ -564,17 +564,12 @@ void xbt_log_init(int *argc, char **argv)
       opt++;
       xbt_log_control_set(opt);
       XBT_DEBUG("Did apply '%s' as log setting", opt);
       opt++;
       xbt_log_control_set(opt);
       XBT_DEBUG("Did apply '%s' as log setting", opt);
-      /*remove this from argv */
-
-      for (j = i + 1; j < *argc; j++) {
-        argv[j - 1] = argv[j];
-      }
-
-      argv[j - 1] = NULL;
-      (*argc)--;
-      i--;                      /* compensate effect of next loop incrementation */
+    } else {
+      argv[j++] = argv[i];
     }
   }
     }
   }
+  argv[j] = NULL;
+  *argc = j;
 }
 
 static void log_cat_exit(xbt_log_category_t cat)
 }
 
 static void log_cat_exit(xbt_log_category_t cat)