diff -r 51b75b45b563 -r 12e555d89149 Array.st --- a/Array.st Mon Aug 03 12:02:00 2015 +0200 +++ b/Array.st Mon Aug 03 12:02:16 2015 +0200 @@ -327,13 +327,18 @@ indx = __intVal(index) - 1; slf = self; + cls = __qClass(slf); nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); - if ((cls = __qClass(slf)) != Array) { - if (indx < 0) goto badIndex; + if (cls == Array) { +fetch: + if ((unsigned INT)indx < (unsigned INT)nIndex) { + RETURN ( __InstPtr(slf)->i_instvars[indx] ); + } + goto badIndex; + } + if (indx >= 0) { indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); - } - if ((unsigned INT)indx < (unsigned INT)nIndex) { - RETURN ( __InstPtr(slf)->i_instvars[indx] ); + goto fetch; } } badIndex: ; @@ -368,15 +373,20 @@ indx = __intVal(index) - 1; slf = self; + cls = __qClass(slf); nIndex = __BYTES2OBJS__(__qSize(slf) - OHDR_SIZE); - if ((cls = __qClass(slf)) != Array) { - if (indx < 0) goto badIndex; - indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); + if (cls == Array) { +store: + if ((unsigned INT)indx < (unsigned INT)nIndex) { + __InstPtr(slf)->i_instvars[indx] = anObject; + __STORE(slf, anObject); + RETURN ( anObject ); + } + goto badIndex; } - if ((unsigned INT)indx < (unsigned INT)nIndex) { - __InstPtr(slf)->i_instvars[indx] = anObject; - __STORE(slf, anObject); - RETURN ( anObject ); + if (indx >= 0) { + indx += __intVal(__ClassInstPtr(cls)->c_ninstvars); + goto store; } } badIndex: ; @@ -1619,138 +1629,138 @@ OBJ myClass; if ( - (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0)) + (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0)) && __isNonNilObject(aCollection) && (((t = __qClass(aCollection)) == Array) || (t == myClass)) && __bothSmallInteger(start, stop) && __isSmallInteger(repStart) ) { - startIndex = __intVal(start) - 1; - if (startIndex >= 0) { - nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); - stopIndex = __intVal(stop) - 1; - count = stopIndex - startIndex + 1; + startIndex = __intVal(start) - 1; + if (startIndex >= 0) { + nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); + stopIndex = __intVal(stop) - 1; + count = stopIndex - startIndex + 1; - if ((count > 0) && (stopIndex < nIndex)) { - repStartIndex = __intVal(repStart) - 1; - if (repStartIndex >= 0) { - repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); - repStopIndex = repStartIndex + (stopIndex - startIndex); - if (repStopIndex < repNIndex) { - src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); - dst = &(__InstPtr(self)->i_instvars[startIndex]); - if (aCollection == self) { - /* - * no need to check stores if copying - * from myself - */ + if ((count > 0) && (stopIndex < nIndex)) { + repStartIndex = __intVal(repStart) - 1; + if (repStartIndex >= 0) { + repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); + repStopIndex = repStartIndex + (stopIndex - startIndex); + if (repStopIndex < repNIndex) { + src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); + dst = &(__InstPtr(self)->i_instvars[startIndex]); + if (aCollection == self) { + /* + * no need to check stores if copying + * from myself + */ - /* - * take care of overlapping copy - * do not depend on memset being smart enough - * (some are not ;-) - */ - if (src < dst) { - /* must do a reverse copy */ - src += count; - dst += count; + /* + * take care of overlapping copy + * do not depend on memset being smart enough + * (some are not ;-) + */ + if (src < dst) { + /* must do a reverse copy */ + src += count; + dst += count; #ifdef __UNROLL_LOOPS__ - while (count > 8) { - dst[-1] = src[-1]; - dst[-2] = src[-2]; - dst[-3] = src[-3]; - dst[-4] = src[-4]; - dst[-5] = src[-5]; - dst[-6] = src[-6]; - dst[-7] = src[-7]; - dst[-8] = src[-8]; - dst -= 8; src -= 8; - count -= 8; - } + while (count > 8) { + dst[-1] = src[-1]; + dst[-2] = src[-2]; + dst[-3] = src[-3]; + dst[-4] = src[-4]; + dst[-5] = src[-5]; + dst[-6] = src[-6]; + dst[-7] = src[-7]; + dst[-8] = src[-8]; + dst -= 8; src -= 8; + count -= 8; + } #endif - while (count-- > 0) { - *--dst = *--src; - } - RETURN ( self ); - } + while (count-- > 0) { + *--dst = *--src; + } + RETURN ( self ); + } #ifdef SOFTWARE_PIPELINE - { - /* - * the loop below fetches one longWord behind - * this should not be a problem - */ - OBJ t1 = src[0]; - count--; - if (count) { - dst++; src++; - do { - dst[-1] = t1; - t1 = src[0]; - src++; - dst++; - } while (count--); - } else { - dst[0] = t1; - } - } + { + /* + * the loop below fetches one longWord behind + * this should not be a problem + */ + OBJ t1 = src[0]; + count--; + if (count) { + dst++; src++; + do { + dst[-1] = t1; + t1 = src[0]; + src++; + dst++; + } while (count--); + } else { + dst[0] = t1; + } + } #else # ifdef bcopy4 - bcopy4(src, dst, count); + bcopy4(src, dst, count); # else # ifdef FAST_MEMCPY - memcpy(dst, src, __OBJS2BYTES__(count)); + memcpy(dst, src, __OBJS2BYTES__(count)); # else # ifdef __UNROLL_LOOPS__ - while (count >= 8) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[4]; - dst[5] = src[5]; - dst[6] = src[6]; - dst[7] = src[7]; - dst += 8; src += 8; - count -= 8; - } + while (count >= 8) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + dst[4] = src[4]; + dst[5] = src[5]; + dst[6] = src[6]; + dst[7] = src[7]; + dst += 8; src += 8; + count -= 8; + } # endif - while (count--) { - *dst++ = *src++; - } + while (count--) { + *dst++ = *src++; + } # endif # endif #endif - } else { - REGISTER int spc = __qSpace(self); + } else { + REGISTER int spc = __qSpace(self); #ifdef __UNROLL_LOOPS__ - while (count >= 8) { - t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); - t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); - t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); - t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); - t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); - t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); - t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); - t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); - count -= 8; src += 8; dst += 8; - } + while (count >= 8) { + t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); + t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); + t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); + t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); + t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); + t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); + t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); + t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); + count -= 8; src += 8; dst += 8; + } #endif - while (count-- > 0) { - t = *src++; - *dst++ = t; - __STORE_SPC(self, t, spc); - } - } - RETURN ( self ); - } - } - } + while (count-- > 0) { + t = *src++; + *dst++ = t; + __STORE_SPC(self, t, spc); + } + } + RETURN ( self ); + } + } + } - if (count == 0) { - RETURN ( self ); - } - } + if (count == 0) { + RETURN ( self ); + } + } } %}. ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart @@ -2690,4 +2700,3 @@ version_CVS ^ '$Header$' ! ! -