1617 REGISTER OBJ t; |
1627 REGISTER OBJ t; |
1618 REGISTER INT count; |
1628 REGISTER INT count; |
1619 OBJ myClass; |
1629 OBJ myClass; |
1620 |
1630 |
1621 if ( |
1631 if ( |
1622 (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0)) |
1632 (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __mkSmallInteger(0)) |
1623 && __isNonNilObject(aCollection) |
1633 && __isNonNilObject(aCollection) |
1624 && (((t = __qClass(aCollection)) == Array) || (t == myClass)) |
1634 && (((t = __qClass(aCollection)) == Array) || (t == myClass)) |
1625 && __bothSmallInteger(start, stop) |
1635 && __bothSmallInteger(start, stop) |
1626 && __isSmallInteger(repStart) |
1636 && __isSmallInteger(repStart) |
1627 ) { |
1637 ) { |
1628 startIndex = __intVal(start) - 1; |
1638 startIndex = __intVal(start) - 1; |
1629 if (startIndex >= 0) { |
1639 if (startIndex >= 0) { |
1630 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
1640 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
1631 stopIndex = __intVal(stop) - 1; |
1641 stopIndex = __intVal(stop) - 1; |
1632 count = stopIndex - startIndex + 1; |
1642 count = stopIndex - startIndex + 1; |
1633 |
1643 |
1634 if ((count > 0) && (stopIndex < nIndex)) { |
1644 if ((count > 0) && (stopIndex < nIndex)) { |
1635 repStartIndex = __intVal(repStart) - 1; |
1645 repStartIndex = __intVal(repStart) - 1; |
1636 if (repStartIndex >= 0) { |
1646 if (repStartIndex >= 0) { |
1637 repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
1647 repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
1638 repStopIndex = repStartIndex + (stopIndex - startIndex); |
1648 repStopIndex = repStartIndex + (stopIndex - startIndex); |
1639 if (repStopIndex < repNIndex) { |
1649 if (repStopIndex < repNIndex) { |
1640 src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
1650 src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
1641 dst = &(__InstPtr(self)->i_instvars[startIndex]); |
1651 dst = &(__InstPtr(self)->i_instvars[startIndex]); |
1642 if (aCollection == self) { |
1652 if (aCollection == self) { |
1643 /* |
1653 /* |
1644 * no need to check stores if copying |
1654 * no need to check stores if copying |
1645 * from myself |
1655 * from myself |
1646 */ |
1656 */ |
1647 |
1657 |
1648 /* |
1658 /* |
1649 * take care of overlapping copy |
1659 * take care of overlapping copy |
1650 * do not depend on memset being smart enough |
1660 * do not depend on memset being smart enough |
1651 * (some are not ;-) |
1661 * (some are not ;-) |
1652 */ |
1662 */ |
1653 if (src < dst) { |
1663 if (src < dst) { |
1654 /* must do a reverse copy */ |
1664 /* must do a reverse copy */ |
1655 src += count; |
1665 src += count; |
1656 dst += count; |
1666 dst += count; |
1657 #ifdef __UNROLL_LOOPS__ |
1667 #ifdef __UNROLL_LOOPS__ |
1658 while (count > 8) { |
1668 while (count > 8) { |
1659 dst[-1] = src[-1]; |
1669 dst[-1] = src[-1]; |
1660 dst[-2] = src[-2]; |
1670 dst[-2] = src[-2]; |
1661 dst[-3] = src[-3]; |
1671 dst[-3] = src[-3]; |
1662 dst[-4] = src[-4]; |
1672 dst[-4] = src[-4]; |
1663 dst[-5] = src[-5]; |
1673 dst[-5] = src[-5]; |
1664 dst[-6] = src[-6]; |
1674 dst[-6] = src[-6]; |
1665 dst[-7] = src[-7]; |
1675 dst[-7] = src[-7]; |
1666 dst[-8] = src[-8]; |
1676 dst[-8] = src[-8]; |
1667 dst -= 8; src -= 8; |
1677 dst -= 8; src -= 8; |
1668 count -= 8; |
1678 count -= 8; |
1669 } |
1679 } |
1670 #endif |
1680 #endif |
1671 while (count-- > 0) { |
1681 while (count-- > 0) { |
1672 *--dst = *--src; |
1682 *--dst = *--src; |
1673 } |
1683 } |
1674 RETURN ( self ); |
1684 RETURN ( self ); |
1675 } |
1685 } |
1676 #ifdef SOFTWARE_PIPELINE |
1686 #ifdef SOFTWARE_PIPELINE |
1677 { |
1687 { |
1678 /* |
1688 /* |
1679 * the loop below fetches one longWord behind |
1689 * the loop below fetches one longWord behind |
1680 * this should not be a problem |
1690 * this should not be a problem |
1681 */ |
1691 */ |
1682 OBJ t1 = src[0]; |
1692 OBJ t1 = src[0]; |
1683 count--; |
1693 count--; |
1684 if (count) { |
1694 if (count) { |
1685 dst++; src++; |
1695 dst++; src++; |
1686 do { |
1696 do { |
1687 dst[-1] = t1; |
1697 dst[-1] = t1; |
1688 t1 = src[0]; |
1698 t1 = src[0]; |
1689 src++; |
1699 src++; |
1690 dst++; |
1700 dst++; |
1691 } while (count--); |
1701 } while (count--); |
1692 } else { |
1702 } else { |
1693 dst[0] = t1; |
1703 dst[0] = t1; |
1694 } |
1704 } |
1695 } |
1705 } |
1696 #else |
1706 #else |
1697 |
1707 |
1698 # ifdef bcopy4 |
1708 # ifdef bcopy4 |
1699 bcopy4(src, dst, count); |
1709 bcopy4(src, dst, count); |
1700 # else |
1710 # else |
1701 # ifdef FAST_MEMCPY |
1711 # ifdef FAST_MEMCPY |
1702 memcpy(dst, src, __OBJS2BYTES__(count)); |
1712 memcpy(dst, src, __OBJS2BYTES__(count)); |
1703 # else |
1713 # else |
1704 # ifdef __UNROLL_LOOPS__ |
1714 # ifdef __UNROLL_LOOPS__ |
1705 while (count >= 8) { |
1715 while (count >= 8) { |
1706 dst[0] = src[0]; |
1716 dst[0] = src[0]; |
1707 dst[1] = src[1]; |
1717 dst[1] = src[1]; |
1708 dst[2] = src[2]; |
1718 dst[2] = src[2]; |
1709 dst[3] = src[3]; |
1719 dst[3] = src[3]; |
1710 dst[4] = src[4]; |
1720 dst[4] = src[4]; |
1711 dst[5] = src[5]; |
1721 dst[5] = src[5]; |
1712 dst[6] = src[6]; |
1722 dst[6] = src[6]; |
1713 dst[7] = src[7]; |
1723 dst[7] = src[7]; |
1714 dst += 8; src += 8; |
1724 dst += 8; src += 8; |
1715 count -= 8; |
1725 count -= 8; |
1716 } |
1726 } |
1717 # endif |
1727 # endif |
1718 while (count--) { |
1728 while (count--) { |
1719 *dst++ = *src++; |
1729 *dst++ = *src++; |
1720 } |
1730 } |
1721 # endif |
1731 # endif |
1722 # endif |
1732 # endif |
1723 #endif |
1733 #endif |
1724 } else { |
1734 } else { |
1725 REGISTER int spc = __qSpace(self); |
1735 REGISTER int spc = __qSpace(self); |
1726 #ifdef __UNROLL_LOOPS__ |
1736 #ifdef __UNROLL_LOOPS__ |
1727 while (count >= 8) { |
1737 while (count >= 8) { |
1728 t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
1738 t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
1729 t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
1739 t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
1730 t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
1740 t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
1731 t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
1741 t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
1732 t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); |
1742 t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); |
1733 t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); |
1743 t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); |
1734 t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); |
1744 t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); |
1735 t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); |
1745 t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); |
1736 count -= 8; src += 8; dst += 8; |
1746 count -= 8; src += 8; dst += 8; |
1737 } |
1747 } |
1738 #endif |
1748 #endif |
1739 while (count-- > 0) { |
1749 while (count-- > 0) { |
1740 t = *src++; |
1750 t = *src++; |
1741 *dst++ = t; |
1751 *dst++ = t; |
1742 __STORE_SPC(self, t, spc); |
1752 __STORE_SPC(self, t, spc); |
1743 } |
1753 } |
1744 } |
1754 } |
1745 RETURN ( self ); |
1755 RETURN ( self ); |
1746 } |
1756 } |
1747 } |
1757 } |
1748 } |
1758 } |
1749 |
1759 |
1750 if (count == 0) { |
1760 if (count == 0) { |
1751 RETURN ( self ); |
1761 RETURN ( self ); |
1752 } |
1762 } |
1753 } |
1763 } |
1754 } |
1764 } |
1755 %}. |
1765 %}. |
1756 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
1766 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
1757 |
1767 |
1758 "Modified: 13.4.1996 / 12:17:13 / cg" |
1768 "Modified: 13.4.1996 / 12:17:13 / cg" |