Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!tymix!cirrusl!sunstorm!dhesi From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: Cryptic code == Optimized code ? YES : NO ; Message-ID: <2514@cirrusl.UUCP> Date: 27 Sep 90 03:32:16 GMT References: <861@gtenmc.UUCP>, <168@thor.UUCP> Sender: news@cirrusl.UUCP Organization: Cirrus Logic Inc. Lines: 13 The real advantage of the exclusive OR method of exchanging two variables is that you can make it into a macro in C. It's a little harder to do that with the temp variable method because it is currently impossible to declare a variable in C without first knowing its type. The real question is whether the swap macro using exclusive OR is faster than a swap() function. I have seen a "typeof" keyword proposed that would fix this deficieny: #define swap(a,b) do { typeof(a) tmp; tmp = a; a = b; b = tmp; } until (0); -- Rahul Dhesi UUCP: oliveb!cirrusl!dhesi