lkml.org 
[lkml]   [2008]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectImproved Swapping Method In sort.c
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/



\
 
 \ /
  Last update: 2008-04-30 19:19    [W:0.057 / U:1.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site