diff -r 35e40a6fc72b -r 1f76060d58a4 Array.st --- a/Array.st Tue Mar 07 22:55:20 1995 +0100 +++ b/Array.st Thu Mar 09 00:40:27 1995 +0100 @@ -21,7 +21,7 @@ COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved -$Header: /cvs/stx/stx/libbasic/Array.st,v 1.21 1995-03-06 19:14:47 claus Exp $ +$Header: /cvs/stx/stx/libbasic/Array.st,v 1.22 1995-03-08 23:36:43 claus Exp $ '! !Array class methodsFor:'documentation'! @@ -42,7 +42,7 @@ version " -$Header: /cvs/stx/stx/libbasic/Array.st,v 1.21 1995-03-06 19:14:47 claus Exp $ +$Header: /cvs/stx/stx/libbasic/Array.st,v 1.22 1995-03-08 23:36:43 claus Exp $ " ! @@ -387,8 +387,9 @@ REGISTER OBJ t; REGISTER int count; - if ((_qClass(self) == Array) - && (_Class(aCollection) == Array) + + if ((_ClassInstPtr(_qClass(self))->c_ninstvars == _MKSMALLINT(0)) + && (((t = _Class(aCollection)) == Array) || (t == _qClass(self))) && __bothSmallInteger(start, stop) && __isSmallInteger(repStart)) { startIndex = _intVal(start) - 1; @@ -431,7 +432,7 @@ # endif #endif } else { - REGISTER int spc; + REGISTER int spc; spc = _qSpace(self); while (count-- > 0) { @@ -480,7 +481,7 @@ /* * first, do a quick check using == - * this does not need a context or method send. + * this does not need a context or message send. * in many cases this will already find a match */ REGISTER int index; @@ -646,7 +647,7 @@ "evaluate the argument, aBlock for each element in the collection. - reimplemented for speed" - |home element| + |home| %{ REGISTER OBJFUNC codeVal; REGISTER int index; @@ -769,7 +770,7 @@ "evaluate the argument, aBlock for each element in the collection in reverse order. - reimplemented for speed" - |home element| + |home| %{ REGISTER OBJFUNC codeVal; REGISTER int index; @@ -814,7 +815,7 @@ up to (and including) stop in the collection. - reimplemented for speed" - |home element| + |home| %{ REGISTER OBJFUNC codeVal; REGISTER int index; @@ -863,11 +864,10 @@ } else { for (index=indexLow; index <= indexHigh; index++) { if (InterruptPending != nil) interruptL(__LINE__ COMMA_CON); - element = _InstPtr(self)->i_instvars[index]; (*val.ilc_func) (aBlock, @symbol(value:), CON_COMMA nil, &val, - element); + _InstPtr(self)->i_instvars[index]); } } } @@ -884,7 +884,7 @@ up to (and including) stop in the collection. Step in reverse order. - reimplemented for speed" - |home element| + |home| %{ REGISTER OBJFUNC codeVal; REGISTER int index; @@ -933,11 +933,10 @@ } else { for (index=indexHigh; index >= indexLow; index--) { if (InterruptPending != nil) interruptL(__LINE__ COMMA_CON); - element = _InstPtr(self)->i_instvars[index]; (*val.ilc_func) (aBlock, @symbol(value:), CON_COMMA nil, &val, - element); + _InstPtr(self)->i_instvars[index]); } } } @@ -952,13 +951,15 @@ nonNilElementsDo:aBlock "evaluate the argument, aBlock for each non-nil element" - |home element| + |home| %{ REGISTER OBJFUNC codeVal; REGISTER int index; int nIndex; extern OBJ Block; static struct inlineCache val = _ILC1; + REGISTER OBJ rHome; + REGISTER OBJ element; index = _intVal(_ClassInstPtr(_qClass(self))->c_ninstvars); nIndex = __BYTES2OBJS__(_qSize(self) - OHDR_SIZE); @@ -975,12 +976,26 @@ } #else home = _BlockInstPtr(aBlock)->b_home; - for (; index < nIndex; index++) { - if (InterruptPending != nil) interrupt(CONARG); + rHome = home; + if ((rHome == nil) || (_qSpace(rHome) >= STACKSPACE)) { + /* + * home will not move - keep in in a register + */ + for (; index < nIndex; index++) { + if (InterruptPending != nil) interrupt(CONARG); - element = _InstPtr(self)->i_instvars[index]; - if (element != nil) - (*codeVal)(home, CON_COMMA element); + element = _InstPtr(self)->i_instvars[index]; + if (element != nil) + (*codeVal)(home, CON_COMMA element); + } + } else { + for (; index < nIndex; index++) { + if (InterruptPending != nil) interrupt(CONARG); + + element = _InstPtr(self)->i_instvars[index]; + if (element != nil) + (*codeVal)(home, CON_COMMA element); + } } #endif } else {