TP 11 exo1: affecting a value cost less than branching
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 13 Mar 2017 14:02:15 +0000 (15:02 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 13 Mar 2017 14:02:15 +0000 (15:02 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP_13/exo1/lib/sort.c

index 0fdb0be30c6ef0c087d8088dc2f3afdc0c0ca18d..70a766b505773ba6e14823aef9b194c9c55c0b95 100644 (file)
@@ -22,7 +22,7 @@ static bool sort_first(int* array, unsigned length, criteria_cb criteria) {
     for (unsigned i = 0; i < length-1; i++) {
         if (criteria(array[i], array[i+1])) {
             swap_int(&array[i], &array[i+1]);
-            if (!rt) { rt = true; };
+            rt = true;
         }
     }
     return rt;