void Func1(){ static int a = 1; static int b = 2; a^=b^=a^=b;}void Func2(){ static int a = 1; static int b = 2; int t = a; a = b; b = t;}
Here's the time it took to run each function 100,000,000 times:
Function 1: 1.868420 seconds
Function 2: 1.264502 seconds
Not only is using a temporary value slightly faster, but it's also much easier to read.
- Houdini
Edited by - Houdini on October 8, 2000 10:07:25 PM