oops - #keysAndValuesDo: was from for subclasses with named instVars
authorClaus Gittinger <cg@exept.de>
Thu, 07 Aug 1997 19:47:43 +0200
changeset 2842 1cda44a3660e
parent 2841 d3cab7c7d334
child 2843 ccf00b7b1c8f
oops - #keysAndValuesDo: was from for subclasses with named instVars
Array.st
--- a/Array.st	Thu Aug 07 17:33:00 1997 +0200
+++ b/Array.st	Thu Aug 07 19:47:43 1997 +0200
@@ -1030,129 +1030,135 @@
      Pass both index and element to the block.
      - reimplemented for speed"
 
-    |sz "{ Class: SmallInteger }" |
-
-    sz := self size.
 %{
     REGISTER OBJFUNC codeVal;
     REGISTER int index;
-    unsigned int nIndex;
     static struct inlineCache val2 = _ILC2;
     REGISTER OBJ rHome;
     int actualSize;
     OBJ myClass;
 
     myClass = __qClass(self);
-    index = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+    if ((__ClassInstPtr(myClass)->c_ninstvars) == __MKSMALLINT(0)) {
 
-    actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
-    nIndex = index + __intVal(sz);
+        actualSize = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+        index = 0;
 
-    if (nIndex <= actualSize) {
-	if (__isBlockLike(aBlock)
-	 && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) {
-	    {
-		/*
-		 * the most common case: a static compiled block, with home on the stack ...
-		 */
-		REGISTER OBJFUNC codeVal;
+        if (index < actualSize) {
+	    if (__isBlockLike(aBlock)
+	     && (__BlockInstPtr(aBlock)->b_nargs == __MKSMALLINT(2))) {
+	        {
+		    /*
+		     * the most common case: a static compiled block, with home on the stack ...
+		     */
+		    REGISTER OBJFUNC codeVal;
 
-                if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil)
+                    if (((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil)
 #ifdef PARANOIA
-                 && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC)))
+                     && (! ((INT)(__BlockInstPtr(aBlock)->b_flags) & __MASKSMALLINT(F_DYNAMIC)))
 #endif
-		) {
+		    ) {
 
 #ifdef NEW_BLOCK_CALL
-#                   define BLOCK_ARG        aBlock
+#                       define BLOCK_ARG        aBlock
 #else
-#                   define BLOCK_ARG        rHome
-		    REGISTER OBJ rHome;
+#                       define BLOCK_ARG        rHome
+		        REGISTER OBJ rHome;
+
+		        rHome = __BlockInstPtr(aBlock)->b_home;
+		        if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+#endif
+		        {
+			    while (index < actualSize) {
+				OBJ el;
+
+			        if (InterruptPending != nil)  __interruptL(@line);
+
+				el = __InstPtr(self)->i_instvars[index];
+			        index++;
 
-		    rHome = __BlockInstPtr(aBlock)->b_home;
-		    if ((rHome == nil) || (__qSpace(rHome) >= STACKSPACE))
+			        (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el);
+			    }
+			    RETURN (self);
+		        }
+		    }
+	        }
+
+	        /*
+	         * sorry, must check code-pointer in the loop
+	         * it could be recompiled or flushed
+	         */
+#               undef BLOCK_ARG
+#ifdef NEW_BLOCK_CALL
+#               define BLOCK_ARG        aBlock
+#               define IBLOCK_ARG       nil
+#else
+#               define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
+#               define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
 #endif
-		    {
-			while (index < nIndex) {
-			    index++;
-			    if (InterruptPending != nil) __interruptL(@line);
+
+	        while (index < actualSize) {
+		    REGISTER OBJFUNC codeVal;
+		    OBJ el;
+
+		    if (InterruptPending != nil) __interruptL(@line);
+
+		    el = __InstPtr(self)->i_instvars[index];
+		    index++;
+		    if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
+		        (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), el);
+		    } else {
+		        if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
+			    /*
+			     * arg is a compiled block with bytecode -
+			     * directly call interpreter without going through Block>>value
+			     */
+#ifdef PASS_ARG_POINTER
+			    {
+			        OBJ t[2];
 
-			    (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
-			}
-			RETURN (self);
+			        t[0] = __MKSMALLINT(index);
+			        t[1] = el;
+
+			        __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t);
+			    }
+#else
+			    __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), el);
+#endif
+		        } else {
+			    (*val2.ilc_func)(aBlock, 
+					        @symbol(value:value:), 
+					        nil, &val2, 
+					        __MKSMALLINT(index),
+					        el);
+		        }
 		    }
-		}
+	        }
+
+#               undef BLOCK_ARG
+#               undef IBLOCK_ARG
+
+	        RETURN (self );
 	    }
 
 	    /*
-	     * sorry, must check code-pointer in the loop
-	     * it could be recompiled or flushed
+	     * not a block - send it #value:
 	     */
-#           undef BLOCK_ARG
-#ifdef NEW_BLOCK_CALL
-#           define BLOCK_ARG        aBlock
-#           define IBLOCK_ARG       nil
-#else
-#           define BLOCK_ARG        (__BlockInstPtr(aBlock)->b_home)
-#           define IBLOCK_ARG       (__BlockInstPtr(aBlock)->b_home)
-#endif
-
-	    while (index < nIndex) {
-		REGISTER OBJFUNC codeVal;
+	    while (index < actualSize) {
+		OBJ el;
 
-		if (InterruptPending != nil) __interruptL(@line);
-
-		index++;
-		if ((codeVal = __BlockInstPtr(aBlock)->b_code) != (OBJFUNC)nil) {
-		    (*codeVal)(BLOCK_ARG, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
-		} else {
-		    if (__BlockInstPtr(aBlock)->b_bytecodes != nil) {
-			/*
-			 * arg is a compiled block with bytecode -
-			 * directly call interpreter without going through Block>>value
-			 */
-#ifdef PASS_ARG_POINTER
-			{
-			    OBJ t[2];
-
-			    t[0] = __MKSMALLINT(index);
-			    t[1] = __InstPtr(self)->i_instvars[index-1];
+	        if (InterruptPending != nil) __interruptL(@line);
 
-			    __interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, t);
-			}
-#else
-			__interpret(aBlock, 2, nil, IBLOCK_ARG, nil, nil, __MKSMALLINT(index), __InstPtr(self)->i_instvars[index-1]);
-#endif
-		    } else {
-			(*val2.ilc_func)(aBlock, 
-					    @symbol(value:value:), 
-					    nil, &val2, 
-					    __MKSMALLINT(index),
-					    __InstPtr(self)->i_instvars[index-1]);
-		    }
-		}
+		el = __InstPtr(self)->i_instvars[index];
+	        index++;
+	        (*val2.ilc_func)(aBlock, 
+				    @symbol(value:value:), 
+				    nil, &val2, 
+				    __MKSMALLINT(index),
+				    el);
 	    }
-
-#           undef BLOCK_ARG
-#           undef IBLOCK_ARG
-
-	    RETURN (self );
-	}
-
-	/*
-	 * not a block - send it #value:
-	 */
-	while (index < nIndex) {
-	    if (InterruptPending != nil) __interruptL(@line);
-
-	    index++;
-	    (*val2.ilc_func)(aBlock, 
-				@symbol(value:value:), 
-				nil, &val2, 
-				__MKSMALLINT(index),
-				__InstPtr(self)->i_instvars[index-1]);
-	}
-	RETURN ( self );
+	    RETURN ( self );
+        }
     }
 %}.
     ^ super keysAndValuesDo:aBlock
@@ -2189,5 +2195,5 @@
 !Array class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.94 1997-07-31 19:37:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.95 1997-08-07 17:47:43 cg Exp $'
 ! !