diff options
author | njl <njl@FreeBSD.org> | 2005-02-08 07:51:14 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2005-02-08 07:51:14 +0000 |
commit | 3e12d206d6a13c356e336df0c941a99288b2fba6 (patch) | |
tree | 2fbbc4495c2801ec899b03762583284d83d706df /sys | |
parent | 960933d8ac53159548bce0375b912d71b7039fdd (diff) | |
download | FreeBSD-src-3e12d206d6a13c356e336df0c941a99288b2fba6.zip FreeBSD-src-3e12d206d6a13c356e336df0c941a99288b2fba6.tar.gz |
Unroll the loop for calculating the 8.3 filename checksum. In testing
on my P3, microbenchmarks show the unrolled version is 78x faster. In
actual use (recursive ls), this gives an average of 9% improvement in
system time and 2% improvement in wall time.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/fs/msdosfs/msdosfs_conv.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c index 72439e4..1f4a32e 100644 --- a/sys/fs/msdosfs/msdosfs_conv.c +++ b/sys/fs/msdosfs/msdosfs_conv.c @@ -909,18 +909,27 @@ win2unixfn(wep, chksum, pmp) } /* - * Compute the checksum of a DOS filename for Win95 use + * Compute the unrolled checksum of a DOS filename for Win95 LFN use. */ u_int8_t winChksum(name) u_int8_t *name; { - int i; u_int8_t s; - for (s = 0, i = 11; --i >= 0; s += *name++) - s = (s << 7)|(s >> 1); - return s; + 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]; + + return (s); } /* |