From: Jérôme Benoit Date: Fri, 10 Mar 2017 08:29:28 +0000 (+0100) Subject: TP 7 exo1: Remove a useless branching in a int* swap function X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2f54ac48ef2c4ab4e87426c2bf89b9f5eef7008b;p=TD_C.git TP 7 exo1: Remove a useless branching in a int* swap function Signed-off-by: Jérôme Benoit --- diff --git a/TP_7/exo1/exo1.c b/TP_7/exo1/exo1.c index c3ae354..6509b06 100644 --- a/TP_7/exo1/exo1.c +++ b/TP_7/exo1/exo1.c @@ -17,11 +17,9 @@ void xorSwap (int *v1, int *v2) { } void swap(int* v1, int* v2) { - if (v1 != v2) { - int tmp = *v1; - *v1 = *v2; - *v2 = tmp; - } + int tmp = *v1; + *v1 = *v2; + *v2 = tmp; } void displayArray(int* array, int count) {