--- a/Array.st Sun May 08 02:26:20 2016 +0200
+++ b/Array.st Sun May 08 02:26:31 2016 +0200
@@ -551,7 +551,7 @@
!
copyWith:something
- "return a new collection containing the receivers elements
+ "return a new collection containing the receiver's elements
and the single new element, newElement.
This is different from concatentation, which expects another collection
as argument, but equivalent to copy-and-addLast.
@@ -567,59 +567,59 @@
REGISTER int spc;
if (__qClass(self) == Array) {
- sz = __qSize(self) + sizeof(OBJ);
- __PROTECT2__(something, self);
- __qAlignedNew(nObj, sz); /* OBJECT ALLOCATION */
- __UNPROTECT2__(self, something);
+ sz = __qSize(self) + sizeof(OBJ);
+ __PROTECT2__(something, self);
+ __qAlignedNew(nObj, sz); /* OBJECT ALLOCATION */
+ __UNPROTECT2__(self, something);
- if (nObj) {
- __InstPtr(nObj)->o_class = Array;
- __qSTORE(nObj, Array);
+ if (nObj) {
+ __InstPtr(nObj)->o_class = Array;
+ __qSTORE(nObj, Array);
- nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
- /*
- * sorry:
- * cannot use bcopy, since we must take care of stores ...
- * could check for: notRemembered + inOld + notLifoRem
- * + not incrGCRunning
- * but: copyWith is not heavily used by real programmers ...
- */
- spc = __qSpace(nObj);
- srcP = __arrayVal(self);
- dstP = __arrayVal(nObj);
+ nIndex = __BYTES2OBJS__(sz - OHDR_SIZE - sizeof(OBJ));
+ /*
+ * sorry:
+ * cannot use bcopy, since we must take care of stores ...
+ * could check for: notRemembered + inOld + notLifoRem
+ * + not incrGCRunning
+ * but: copyWith is not heavily used by real programmers ...
+ */
+ spc = __qSpace(nObj);
+ srcP = __arrayVal(self);
+ dstP = __arrayVal(nObj);
#ifdef __UNROLL_LOOPS__
- while (nIndex >= 4) {
- OBJ element;
+ while (nIndex >= 4) {
+ OBJ element;
- element = srcP[0];
- dstP[0] = element;
- __STORE_SPC(nObj, element, spc);
- element = srcP[1];
- dstP[1] = element;
- __STORE_SPC(nObj, element, spc);
- element = srcP[2];
- dstP[2] = element;
- __STORE_SPC(nObj, element, spc);
- element = srcP[3];
- dstP[3] = element;
- __STORE_SPC(nObj, element, spc);
- srcP += 4;
- dstP += 4;
- nIndex -= 4;
- }
+ element = srcP[0];
+ dstP[0] = element;
+ __STORE_SPC(nObj, element, spc);
+ element = srcP[1];
+ dstP[1] = element;
+ __STORE_SPC(nObj, element, spc);
+ element = srcP[2];
+ dstP[2] = element;
+ __STORE_SPC(nObj, element, spc);
+ element = srcP[3];
+ dstP[3] = element;
+ __STORE_SPC(nObj, element, spc);
+ srcP += 4;
+ dstP += 4;
+ nIndex -= 4;
+ }
#endif
- while (nIndex--) {
- OBJ element;
+ while (nIndex--) {
+ OBJ element;
- element = *srcP++;
- *dstP++ = element;
- __STORE_SPC(nObj, element, spc);
- }
- *dstP = something;
- __STORE_SPC(nObj, something, spc);
- RETURN ( nObj );
- }
+ element = *srcP++;
+ *dstP++ = element;
+ __STORE_SPC(nObj, element, spc);
+ }
+ *dstP = something;
+ __STORE_SPC(nObj, something, spc);
+ RETURN ( nObj );
+ }
}
%}.
^ super copyWith:something