From 2f54ac48ef2c4ab4e87426c2bf89b9f5eef7008b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 10 Mar 2017 09:29:28 +0100 Subject: [PATCH] TP 7 exo1: Remove a useless branching in a int* swap function MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TP_7/exo1/exo1.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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) { -- 2.34.1