Hand optimized copying

Richard Harter g-rh at XAIT.Xerox.COM
Wed Oct 19 01:41:42 AEST 1988


In article <10130002 at hpisod1.HP.COM> renglish at hpisod1.HP.COM (Robert English) writes:
]/ g-rh at XAIT.Xerox.COM (Richard Harter) /  2:38 pm  Oct  7, 1988 /

]> #define copy(dest,src,nb) {register char *a, *b; register int i;\
]> a = dest; b = src;\
]> for (i = (nb %7)+1; --i;) *a++ = *b++;\
]> for (i = (nb>>3)+1; --i>0;) {\
]> *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++;\
]> *a++ = *b++; *a++ = *b++; *a++ = *b++; *a++ = *b++;\
]> }}

]Methinks that line 3 should read:
]for (i = (nb & 07) + 1; --i;)...
]( or " % 8" )

You are correct -- it should read &7 rather than %7.  %8 is slightly
more expensive.  The "%" is a typo.  Also as noted previously, the 
variable a, b, and i should by replaced names specific to the macro,
and dest, src, and nb should be in parenthesis.

-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.



More information about the Comp.lang.c mailing list