lkml.org 
[lkml]   [2008]   [May]   [2]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateThu, 01 May 2008 22:05:16 -0700
From"H. Peter Anvin" <>
SubjectRe: Improved Swapping Method In sort.c
Soumyadip Das Mahapatra wrote:
> 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;
> }
> 

Not only is this invalid C, but it produces massively worse code.

	-hpa


\
 
 \ /
  Last update: 2008-05-02 07:11    [from the cache]
©2003-2008