diff options
author | robert <robert@FreeBSD.org> | 2002-08-30 20:33:05 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2002-08-30 20:33:05 +0000 |
commit | 9920d9cacdfab69203ac25c6e4935daa83ba456c (patch) | |
tree | bbcfbe7e8b5519fd93596d68c5a090a398784294 /lib/libc/string/swab.c | |
parent | 1286c989d680b02f88a9c13952bbb57e99e7fbac (diff) | |
download | FreeBSD-src-9920d9cacdfab69203ac25c6e4935daa83ba456c.zip FreeBSD-src-9920d9cacdfab69203ac25c6e4935daa83ba456c.tar.gz |
- Convert the function definition to declare its arguments
in the ANSI-C format.
- Change the code a bit to hopefully save some cycles.
I.e. (simplified) change
a = b + 1;
while (--b & 0x7)
/* ... */
to
a = b;
for (; b & 0x7; b--)
/* ... */
and
while (--a >= 0)
/* ... */
to
for (; a > 0; a--)
/* ... */
- Equip two function arguments of swab() with the 'restrict'
type qualifier in form of the '__restrict' macro. This is
specified by POSIX.1-2001.
Diffstat (limited to 'lib/libc/string/swab.c')
-rw-r--r-- | lib/libc/string/swab.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c index 70da36f..aa6f268 100644 --- a/lib/libc/string/swab.c +++ b/lib/libc/string/swab.c @@ -43,24 +43,20 @@ __FBSDID("$FreeBSD$"); #include <string.h> void -swab(from, to, len) - const void *from; - void *to; - size_t len; +swab(const void * __restrict from, void * __restrict to, size_t len) { unsigned long temp; int n; char *fp, *tp; - n = (len >> 1) + 1; + n = len >> 1; fp = (char *)from; tp = (char *)to; #define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp /* round to multiple of 8 */ - while ((--n) & 07) + for (; n & 0x7; --n) STEP; - n >>= 3; - while (--n >= 0) { + for (n >>= 3; n > 0; --n) { STEP; STEP; STEP; STEP; STEP; STEP; STEP; STEP; } |