Improved Swapping Method In sort.c
- From: Soumyadip Das Mahapatra <dip_kernel@xxxxxxxxxxx>
- Date: Wed, 30 Apr 2008 22:39:14 +0530 (IST)
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/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: Improved Swapping Method In sort.c
- From: David Newall
- Re: Improved Swapping Method In sort.c
- From: Jan Engelhardt
- Re: Improved Swapping Method In sort.c
- From: Jan Engelhardt
- Re: Improved Swapping Method In sort.c
- Prev by Date: Re: Problem with 8250_pnp Module and using ttyS0 as console
- Next by Date: Mail problems at hera.kernel.org
- Previous by thread: Problem with 8250_pnp Module and using ttyS0 as console
- Next by thread: Re: Improved Swapping Method In sort.c
- Index(es):
Relevant Pages
|