From 9920d9cacdfab69203ac25c6e4935daa83ba456c Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 30 Aug 2002 20:33:05 +0000 Subject: - 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. --- lib/libc/string/swab.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib/libc/string/swab.c') 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 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; } -- cgit v1.1