[lkml]   [2008]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Improved Swapping Method In sort.c

On Wednesday 2008-04-30 19:09, 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.

GCC is smart enough to optimize the current instructions into a
bswap instruction or similar. While with xor, some are said to fail -
and three xor operations are surely slower than a swap if there is
a swap instruction.

Never heard of that?

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