optimize swap

This commit is contained in:
Chris Cromer 2018-11-17 17:00:00 -03:00
parent 751e6d9cb4
commit 6ff4147448
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A

View File

@ -19,7 +19,10 @@
* @param yp Segundo valor
*/
void swap(int *xp, int *yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
if (xp == yp) {
return;
}
*xp = *xp + *yp;
*yp = *xp - *yp;
*xp = *xp - *yp;
}