Re: Improved Swapping Method In sort.c

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Newall
Date: Wednesday, April 30, 2008 - 11:46 am

Soumyadip Das Mahapatra wrote:

That was posted to comp.lang.c 20 years ago or more.  It's not something
that the compiler is likely to be able to optimize (unlike the normal
swap, using a temporary variable.)

Another cute, temp-free swap, from the same era, is: b += a -= b; a = b - a.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Improved Swapping Method In sort.c, Soumyadip Das Mahapatra, (Wed Apr 30, 10:09 am)
Re: Improved Swapping Method In sort.c, Jan Engelhardt, (Wed Apr 30, 10:30 am)
Re: Improved Swapping Method In sort.c, Jan Engelhardt, (Wed Apr 30, 10:33 am)
Re: Improved Swapping Method In sort.c, Sami Farin, (Wed Apr 30, 11:03 am)
Re: Improved Swapping Method In sort.c, David Newall, (Wed Apr 30, 11:46 am)
Re: Improved Swapping Method In sort.c, H. Peter Anvin, (Thu May 1, 10:05 pm)