ByteArray.st
changeset 24246 5891fd2af1ec
parent 23925 fcde2f1eefbe
child 24314 51288ad97cc9
--- a/ByteArray.st	Tue Jun 04 00:53:27 2019 +0200
+++ b/ByteArray.st	Tue Jun 04 00:54:15 2019 +0200
@@ -205,6 +205,7 @@
 
 
 
+
 !ByteArray methodsFor:'Compatibility-Squeak'!
 
 bitXor:aByteArray
@@ -2322,8 +2323,9 @@
 !
 
 invert
-    "invert all bytes - used with image manipulations
+    "invert all bytes inplace - used with image manipulations
      written as a primitive for speed.
+     Warning: destructive; modifies the receiver - not a copy.
      Q: is this really needed ?"
 
 %{  /* NOCONTEXT */
@@ -2332,30 +2334,30 @@
     REGISTER int cnt;
 
     if (__qClass(self) == @global(ByteArray)) {
-	cnt = __byteArraySize(self);
-	dst = __ByteArrayInstPtr(self)->ba_element;
-	if (((INT)dst & (sizeof(long)-1)) == 0) { // aligned
-	    ldst = (unsigned long *)dst;
-	    while (cnt >= (sizeof(long))*4) {
-		ldst[0] = ~(ldst[0]);
-		ldst[1] = ~(ldst[1]);
-		ldst[2] = ~(ldst[2]);
-		ldst[3] = ~(ldst[3]);
-		ldst += 4;
-		cnt -= (sizeof(long))*4;
-	    }
-	    while (cnt >= sizeof(long)) {
-		*ldst = ~(*ldst);
-		ldst++;
-		cnt -= sizeof(long);
-	    }
-	    dst = (unsigned char *)ldst;
-	}
-	while (cnt--) {
-	    *dst = ~(*dst);
-	    dst++;
-	}
-	RETURN ( self );
+        cnt = __byteArraySize(self);
+        dst = __ByteArrayInstPtr(self)->ba_element;
+        if (((INT)dst & (sizeof(long)-1)) == 0) { // aligned
+            ldst = (unsigned long *)dst;
+            while (cnt >= (sizeof(long))*4) {
+                ldst[0] = ~(ldst[0]);
+                ldst[1] = ~(ldst[1]);
+                ldst[2] = ~(ldst[2]);
+                ldst[3] = ~(ldst[3]);
+                ldst += 4;
+                cnt -= (sizeof(long))*4;
+            }
+            while (cnt >= sizeof(long)) {
+                *ldst = ~(*ldst);
+                ldst++;
+                cnt -= sizeof(long);
+            }
+            dst = (unsigned char *)ldst;
+        }
+        while (cnt--) {
+            *dst = ~(*dst);
+            dst++;
+        }
+        RETURN ( self );
     }
 %}.
     self bitBlitBytesFrom:1 to:self size withConstant:16rFF rule:#bitXor:
@@ -2363,14 +2365,16 @@
     "
      #[1 2 3 4 5 6 7 8 9 10] copy invert
      #[1 2 3 4 5 6 7 8 9 10] copy
-	bitBlitBytesFrom:1 to:10 withConstant:16rFF rule:#bitXor:
+        bitBlitBytesFrom:1 to:10 withConstant:16rFF rule:#bitXor:
 
      |l|
      l := ByteArray fromHexString:'0102030405060708090a0b0c0d0e0f1112131415161718191a1b1c1d1e1f'.
      Time millisecondsToRun:[
-	1000000 timesRepeat:[ l invert ].
+        1000000 timesRepeat:[ l invert ].
      ]
     "
+
+    "Modified (comment): / 03-06-2019 / 18:08:47 / Claus Gittinger"
 !
 
 reverse