swap (a, b) suggestion

Stephen Williams steve@icarus.icarus.com
Mon Jan 5 15:21:00 GMT 1998


On Sat, Jan 03, 1998 at 06:11:23PM -0500, Eric Buddington wrote:
> For integer values, the following works, and is significantly faster:
> 
> template <class T>
> inline void swap(T& a, T& b) {
>   a ^= b;
>   b ^= a;
>   a ^= b;
> }

rth@cygnus.com said:
> If it is faster at all I'll warrent it is only so for depressingly
> register starved machines. 

You mean like ix86 machines?

--steve





More information about the Gcc mailing list