public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Improved Swapping Method In sort.c
@ 2008-04-30 17:09 Soumyadip Das Mahapatra
  2008-04-30 17:30 ` Jan Engelhardt
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Soumyadip Das Mahapatra @ 2008-04-30 17:09 UTC (permalink / raw)
  To: linux-kernel

Hello everybody,
The swapping method (in function void u32_swap() line no.. 14 to 16) in lib/sort.c can be improved by using the following code
*(u32 *)b ^= *(u32 *)a ^= *(u32 *)b ^= *(u32 *)a instead of the code given. This code
is not using third variable thus not consuming another memory. And I dont see any significance in
using *int size* argument. so the function should be
static void u32_swap(void *a, void *b)
{
    *(u32 *)b ^= *(u32 *)a ^= *(u32 *)b ^= *(u32 *)a;
}




      Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-02  5:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-30 17:09 Improved Swapping Method In sort.c Soumyadip Das Mahapatra
2008-04-30 17:30 ` Jan Engelhardt
2008-04-30 17:33 ` Jan Engelhardt
2008-04-30 18:03   ` Sami Farin
2008-04-30 18:46 ` David Newall
2008-05-02  5:05 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox