ByteArray.st
changeset 11509 a4de3b9de9ec
parent 11502 64d1cb6c2062
child 11796 b53df9678de9
child 17711 39faaaf888b4
--- a/ByteArray.st	Mon Feb 02 17:47:33 2009 +0100
+++ b/ByteArray.st	Mon Feb 02 18:15:04 2009 +0100
@@ -924,61 +924,76 @@
     INT addrDelta;
 
     if (s == self) {
-	RETURN ( true );
+        RETURN ( true );
     }
     if (! __isNonNilObject(s)) {
-	RETURN ( false );
+        RETURN ( false );
     }
 
     cls = __qClass(s);
     myCls = __qClass(self);
 
     if (cls == myCls) {
-	cp2 = __stringVal(s);
-	l2 = __byteArraySize(s);
-
-	cp1 = __stringVal(self);
-	l1 = __byteArraySize(self);
-
-	if (l1 != l2) {
-	    RETURN ( false );
-	}
-
-	/*
-	 * care for instances of subclasses ...
-	 */
-	if (cls != ByteArray) {
-	    int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-
-	    cp2 += n;
-	    cp1 += n;
-	    l1 -= n;
-	}
-
-	addrDelta = cp2 - cp1;
-	while (l1 >= sizeof(unsigned INT)) {
-	    if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
-		RETURN (false);
-	    }
-	    l1 -= sizeof(unsigned INT);
-	    cp1 += sizeof(unsigned INT);
-	}
-	if (l1 >= sizeof(unsigned short)) {
-	    if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
-		RETURN (false);
-	    }
-	    l1 -= sizeof(unsigned short);
-	    cp1 += sizeof(unsigned short);
-	}
-	while (l1) {
-	    if (*cp1 != *(cp1+addrDelta)) {
-		RETURN (false);
-	    }
-	    l1--;
-	    cp1++;
-	}
-
-	RETURN (true);
+        l2 = __byteArraySize(s);
+        l1 = __byteArraySize(self);
+        if (l1 != l2) {
+            RETURN ( false );
+        }
+
+        cp1 = __stringVal(self);
+        cp2 = __stringVal(s);
+
+        /*
+         * care for instances of subclasses ...
+         */
+        if (cls != ByteArray) {
+            int n = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+
+            cp2 += n;
+            cp1 += n;
+            l1 -= n;
+        }
+
+        addrDelta = cp2 - cp1;
+        while (l1 >= (sizeof(unsigned INT) * 4)) {
+            if (((unsigned INT *)cp1)[0] != ((unsigned INT *)(cp1+addrDelta))[0]) {
+                RETURN (false);
+            }
+            if (((unsigned INT *)cp1)[1] != ((unsigned INT *)(cp1+addrDelta))[1]) {
+                RETURN (false);
+            }
+            if (((unsigned INT *)cp1)[2] != ((unsigned INT *)(cp1+addrDelta))[2]) {
+                RETURN (false);
+            }
+            if (((unsigned INT *)cp1)[3] != ((unsigned INT *)(cp1+addrDelta))[3]) {
+                RETURN (false);
+            }
+            l1 -= sizeof(unsigned INT)*4;
+            cp1 += sizeof(unsigned INT)*4;
+        }
+        while (l1 >= sizeof(unsigned INT)) {
+            if (*((unsigned INT *)cp1) != *((unsigned INT *)(cp1+addrDelta))) {
+                RETURN (false);
+            }
+            l1 -= sizeof(unsigned INT);
+            cp1 += sizeof(unsigned INT);
+        }
+        if (l1 >= sizeof(unsigned short)) {
+            if (*((unsigned short *)cp1) != *((unsigned short *)(cp1+addrDelta))) {
+                RETURN (false);
+            }
+            l1 -= sizeof(unsigned short);
+            cp1 += sizeof(unsigned short);
+        }
+        while (l1) {
+            if (*cp1 != *(cp1+addrDelta)) {
+                RETURN (false);
+            }
+            l1--;
+            cp1++;
+        }
+
+        RETURN (true);
     }
 %}.
     ^ super = aByteArray
@@ -3195,5 +3210,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.187 2009-02-01 02:08:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.188 2009-02-02 17:15:04 cg Exp $'
 ! !