which way is faster?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



See this code piece

http://lxr.linux.no/source/drivers/scsi/libata-scsi.c?v=2.6.18#L1049

1056         lba |= ((u64)scsicmd[2]) << 24;
1057         lba |= ((u64)scsicmd[3]) << 16;
1058         lba |= ((u64)scsicmd[4]) << 8;
1059         lba |= ((u64)scsicmd[5]);

it can also be written as 

lba = be32_to_cpu(*(u32 *)(&scsicmd[2])


i wrote a simple code to test this and i found second one is several
time faster than first one.

if there any pitfall with 2nd way?

Thanks

Ming



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux