lkml.org 
[lkml]   [2015]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] fs/fat: calculate checksum in a loop instead of directly calculating
Date
Alexander Kuleshov <kuleshovmail@gmail.com> writes:

> static inline unsigned char fat_checksum(const __u8 *name)
> {
> + u8 i;
> unsigned char s = name[0];
> - s = (s<<7) + (s>>1) + name[1]; s = (s<<7) + (s>>1) + name[2];
> - s = (s<<7) + (s>>1) + name[3]; s = (s<<7) + (s>>1) + name[4];
> - s = (s<<7) + (s>>1) + name[5]; s = (s<<7) + (s>>1) + name[6];
> - s = (s<<7) + (s>>1) + name[7]; s = (s<<7) + (s>>1) + name[8];
> - s = (s<<7) + (s>>1) + name[9]; s = (s<<7) + (s>>1) + name[10];
> +
> + for (i = 1; i < 11; i++)
> + s = (s << 7) + (s >> 1) + name[i];
> +
> return s;
> }

When I wrote this, IIRC, there was measurable performance
difference. All major gcc versions are enough smart now to optimize this?
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>


\
 
 \ /
  Last update: 2015-02-18 20:41    [W:0.081 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site