--- a/ByteArray.st Wed May 14 16:44:23 1997 +0200
+++ b/ByteArray.st Wed May 14 16:54:38 1997 +0200
@@ -1290,9 +1290,7 @@
%{ /* NOCONTEXT */
-#if !defined(FAST_MEMCPY)
REGISTER unsigned char *srcp;
-#endif
REGISTER unsigned char *dstp;
REGISTER int count;
int len, index1, index2, sz;
@@ -1314,10 +1312,25 @@
if (newByteArray != nil) {
__InstPtr(newByteArray)->o_class = ByteArray;
dstp = __ByteArrayInstPtr(newByteArray)->ba_element;
+ srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
+
+#ifdef bcopy4
+ if ((((unsigned)srcp & 3) == 0)
+ && (((unsigned)dstp & 3) == 0)) {
+ /* copy aligned part */
+ int nW = count >> 2;
+
+ if (count & 3) {
+ nW++;
+ }
+ bcopy4(srcp, dstp, nW);
+ RETURN ( newByteArray );
+ }
+#endif /* bcopy4 */
+
#ifdef FAST_MEMCPY
- bcopy(__ByteArrayInstPtr(self)->ba_element + index1 - 1, dstp, count);
+ bcopy(srcp, dstp, count);
#else
- srcp = __ByteArrayInstPtr(self)->ba_element + index1 - 1;
while (count--) {
*dstp++ = *srcp++;
}
@@ -1489,13 +1502,11 @@
int nW = count >> 2;
bcopy4(src, dst, nW);
- /* copy rest */
- if (count & 3) {
- src += (count & ~3);
- dst += (count & ~3);
- count = count & 3;
+ if ((count = count & 3) != 0) {
+ src += (nW<<2);
+ dst += (nW<<2);
while (count--) {
- *dst++ = *src++;
+ *dst++ = *src++;
}
}
RETURN ( self );
@@ -2310,5 +2321,5 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.79 1997-04-24 14:23:20 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.80 1997-05-14 14:54:38 cg Exp $'
! !