1455 REGISTER OBJ t; |
1455 REGISTER OBJ t; |
1456 REGISTER int count; |
1456 REGISTER int count; |
1457 OBJ myClass; |
1457 OBJ myClass; |
1458 |
1458 |
1459 if ( |
1459 if ( |
1460 (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __MKSMALLINT(0)) |
1460 (__ClassInstPtr((myClass = __qClass(self)))->c_ninstvars == __MKSMALLINT(0)) |
1461 && __isNonNilObject(aCollection) |
1461 && __isNonNilObject(aCollection) |
1462 && (((t = __qClass(aCollection)) == Array) || (t == myClass)) |
1462 && (((t = __qClass(aCollection)) == Array) || (t == myClass)) |
1463 && __bothSmallInteger(start, stop) |
1463 && __bothSmallInteger(start, stop) |
1464 && __isSmallInteger(repStart) |
1464 && __isSmallInteger(repStart) |
1465 ) { |
1465 ) { |
1466 startIndex = __intVal(start) - 1; |
1466 startIndex = __intVal(start) - 1; |
1467 if (startIndex >= 0) { |
1467 if (startIndex >= 0) { |
1468 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
1468 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
1469 stopIndex = __intVal(stop) - 1; |
1469 stopIndex = __intVal(stop) - 1; |
1470 count = stopIndex - startIndex + 1; |
1470 count = stopIndex - startIndex + 1; |
1471 |
1471 |
1472 if ((count > 0) && (stopIndex < nIndex)) { |
1472 if ((count > 0) && (stopIndex < nIndex)) { |
1473 repStartIndex = __intVal(repStart) - 1; |
1473 repStartIndex = __intVal(repStart) - 1; |
1474 if (repStartIndex >= 0) { |
1474 if (repStartIndex >= 0) { |
1475 repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
1475 repNIndex = __BYTES2OBJS__(__qSize(aCollection)-OHDR_SIZE); |
1476 repStopIndex = repStartIndex + (stopIndex - startIndex); |
1476 repStopIndex = repStartIndex + (stopIndex - startIndex); |
1477 if (repStopIndex < repNIndex) { |
1477 if (repStopIndex < repNIndex) { |
1478 src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
1478 src = &(__InstPtr(aCollection)->i_instvars[repStartIndex]); |
1479 dst = &(__InstPtr(self)->i_instvars[startIndex]); |
1479 dst = &(__InstPtr(self)->i_instvars[startIndex]); |
1480 if (aCollection == self) { |
1480 if (aCollection == self) { |
1481 /* |
1481 /* |
1482 * no need to check stores if copying |
1482 * no need to check stores if copying |
1483 * from myself |
1483 * from myself |
1484 */ |
1484 */ |
1485 |
1485 |
1486 /* |
1486 /* |
1487 * take care of overlapping copy |
1487 * take care of overlapping copy |
1488 * do not depend on memset being smart enough |
1488 * do not depend on memset being smart enough |
1489 * (some are not ;-) |
1489 * (some are not ;-) |
1490 */ |
1490 */ |
1491 if (src < dst) { |
1491 if (src < dst) { |
1492 /* must do a reverse copy */ |
1492 /* must do a reverse copy */ |
1493 src += count; |
1493 src += count; |
1494 dst += count; |
1494 dst += count; |
1495 #if defined(UNROLL_LOOPS) |
1495 #if defined(UNROLL_LOOPS) |
1496 while (count > 8) { |
1496 while (count > 8) { |
1497 dst[-1] = src[-1]; |
1497 dst[-1] = src[-1]; |
1498 dst[-2] = src[-2]; |
1498 dst[-2] = src[-2]; |
1499 dst[-3] = src[-3]; |
1499 dst[-3] = src[-3]; |
1500 dst[-4] = src[-4]; |
1500 dst[-4] = src[-4]; |
1501 dst[-5] = src[-5]; |
1501 dst[-5] = src[-5]; |
1502 dst[-6] = src[-6]; |
1502 dst[-6] = src[-6]; |
1503 dst[-7] = src[-7]; |
1503 dst[-7] = src[-7]; |
1504 dst[-8] = src[-8]; |
1504 dst[-8] = src[-8]; |
1505 dst -= 8; src -= 8; |
1505 dst -= 8; src -= 8; |
1506 count -= 8; |
1506 count -= 8; |
1507 } |
1507 } |
1508 #endif |
1508 #endif |
1509 while (count-- > 0) { |
1509 while (count-- > 0) { |
1510 *--dst = *--src; |
1510 *--dst = *--src; |
1511 } |
1511 } |
1512 RETURN ( self ); |
1512 RETURN ( self ); |
1513 } |
1513 } |
1514 #ifdef SOFTWARE_PIPELINE |
1514 #ifdef SOFTWARE_PIPELINE |
1515 { |
1515 { |
1516 OBJ t1; |
1516 OBJ t1; |
1517 |
1517 |
1518 /* |
1518 /* |
1519 * the loop below fetches one longWord behind |
1519 * the loop below fetches one longWord behind |
1520 * this should not be a problem |
1520 * this should not be a problem |
1521 */ |
1521 */ |
1522 t1 = src[0]; |
1522 t1 = src[0]; |
1523 count--; |
1523 count--; |
1524 if (count) { |
1524 if (count) { |
1525 dst++; src++; |
1525 dst++; src++; |
1526 do { |
1526 do { |
1527 dst[-1] = t1; |
1527 dst[-1] = t1; |
1528 t1 = src[0]; |
1528 t1 = src[0]; |
1529 src++; |
1529 src++; |
1530 dst++; |
1530 dst++; |
1531 } while (count--); |
1531 } while (count--); |
1532 } else { |
1532 } else { |
1533 dst[0] = t1; |
1533 dst[0] = t1; |
1534 } |
1534 } |
1535 } |
1535 } |
1536 #else |
1536 #else |
1537 |
1537 |
1538 # ifdef bcopy4 |
1538 # ifdef bcopy4 |
1539 bcopy4(src, dst, count); |
1539 bcopy4(src, dst, count); |
1540 # else |
1540 # else |
1541 # ifdef FAST_MEMCPY |
1541 # ifdef FAST_MEMCPY |
1542 bcopy(src, dst, __OBJS2BYTES__(count)); |
1542 bcopy(src, dst, __OBJS2BYTES__(count)); |
1543 # else |
1543 # else |
1544 # if defined(UNROLL_LOOPS) |
1544 # if defined(UNROLL_LOOPS) |
1545 while (count >= 8) { |
1545 while (count >= 8) { |
1546 dst[0] = src[0]; |
1546 dst[0] = src[0]; |
1547 dst[1] = src[1]; |
1547 dst[1] = src[1]; |
1548 dst[2] = src[2]; |
1548 dst[2] = src[2]; |
1549 dst[3] = src[3]; |
1549 dst[3] = src[3]; |
1550 dst[4] = src[4]; |
1550 dst[4] = src[4]; |
1551 dst[5] = src[5]; |
1551 dst[5] = src[5]; |
1552 dst[6] = src[6]; |
1552 dst[6] = src[6]; |
1553 dst[7] = src[7]; |
1553 dst[7] = src[7]; |
1554 dst += 8; src += 8; |
1554 dst += 8; src += 8; |
1555 count -= 8; |
1555 count -= 8; |
1556 } |
1556 } |
1557 # endif |
1557 # endif |
1558 while (count--) { |
1558 while (count--) { |
1559 *dst++ = *src++; |
1559 *dst++ = *src++; |
1560 } |
1560 } |
1561 # endif |
1561 # endif |
1562 # endif |
1562 # endif |
1563 #endif |
1563 #endif |
1564 } else { |
1564 } else { |
1565 REGISTER int spc; |
1565 REGISTER int spc; |
1566 |
1566 |
1567 spc = __qSpace(self); |
1567 spc = __qSpace(self); |
1568 #if defined(UNROLL_LOOPS) |
1568 #if defined(UNROLL_LOOPS) |
1569 while (count >= 8) { |
1569 while (count >= 8) { |
1570 t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
1570 t = src[0]; dst[0] = t; __STORE_SPC(self, t, spc); |
1571 t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
1571 t = src[1]; dst[1] = t; __STORE_SPC(self, t, spc); |
1572 t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
1572 t = src[2]; dst[2] = t; __STORE_SPC(self, t, spc); |
1573 t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
1573 t = src[3]; dst[3] = t; __STORE_SPC(self, t, spc); |
1574 t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); |
1574 t = src[4]; dst[4] = t; __STORE_SPC(self, t, spc); |
1575 t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); |
1575 t = src[5]; dst[5] = t; __STORE_SPC(self, t, spc); |
1576 t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); |
1576 t = src[6]; dst[6] = t; __STORE_SPC(self, t, spc); |
1577 t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); |
1577 t = src[7]; dst[7] = t; __STORE_SPC(self, t, spc); |
1578 count -= 8; src += 8; dst += 8; |
1578 count -= 8; src += 8; dst += 8; |
1579 } |
1579 } |
1580 #endif |
1580 #endif |
1581 while (count-- > 0) { |
1581 while (count-- > 0) { |
1582 t = *src++; |
1582 t = *src++; |
1583 *dst++ = t; |
1583 *dst++ = t; |
1584 __STORE_SPC(self, t, spc); |
1584 __STORE_SPC(self, t, spc); |
1585 } |
1585 } |
1586 } |
1586 } |
1587 RETURN ( self ); |
1587 RETURN ( self ); |
1588 } |
1588 } |
1589 } |
1589 } |
1590 } |
1590 } |
1591 |
1591 |
1592 if (count == 0) { |
1592 if (count == 0) { |
1593 RETURN ( self ); |
1593 RETURN ( self ); |
1594 } |
1594 } |
1595 } |
1595 } |
1596 } |
1596 } |
1597 %}. |
1597 %}. |
1598 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
1598 ^ super replaceFrom:start to:stop with:aCollection startingAt:repStart |
1599 |
1599 |
1600 "Modified: 13.4.1996 / 12:17:13 / cg" |
1600 "Modified: 13.4.1996 / 12:17:13 / cg" |
1997 static struct inlineCache eq = _ILC1; |
1997 static struct inlineCache eq = _ILC1; |
1998 OBJ myClass, e; |
1998 OBJ myClass, e; |
1999 |
1999 |
2000 myClass = __qClass(self); |
2000 myClass = __qClass(self); |
2001 if ( __isSmallInteger(start) ) { |
2001 if ( __isSmallInteger(start) ) { |
2002 index = __intVal(start) - 1; |
2002 index = __intVal(start) - 1; |
2003 if (index >= 0) { |
2003 if (index >= 0) { |
2004 nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
2004 nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
2005 index += nInsts; |
2005 index += nInsts; |
2006 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
2006 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
2007 |
2007 |
2008 e = anElement; |
2008 e = anElement; |
2009 if (e != nil) { |
2009 if (e != nil) { |
2010 /* |
2010 /* |
2011 * special kludge to search for a string; |
2011 * special kludge to search for a string; |
2012 * this is so common, that its worth a special case |
2012 * this is so common, that its worth a special case |
2013 */ |
2013 */ |
2014 #define SPECIAL_STRING_OPT |
2014 #define SPECIAL_STRING_OPT |
2015 #ifdef SPECIAL_STRING_OPT |
2015 #ifdef SPECIAL_STRING_OPT |
2016 if (__isString(e)) { |
2016 if (__isString(e)) { |
2017 while (index < nIndex) { |
2017 while (index < nIndex) { |
2018 element = __InstPtr(self)->i_instvars[index++]; |
2018 element = __InstPtr(self)->i_instvars[index++]; |
2019 if (__isNonNilObject(element)) { |
2019 if (__isNonNilObject(element)) { |
2020 if (element == e) { |
2020 if (element == e) { |
2021 RETURN ( __MKSMALLINT(index - nInsts) ); |
2021 RETURN ( __MKSMALLINT(index - nInsts) ); |
2022 } |
2022 } |
2023 if (__qClass(element) == @global(String)) { |
2023 if (__qClass(element) == @global(String)) { |
2024 if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
2024 if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
2025 RETURN ( __MKSMALLINT(index - nInsts) ); |
2025 RETURN ( __MKSMALLINT(index - nInsts) ); |
2026 } |
2026 } |
2027 } else { |
2027 } else { |
2028 if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
2028 if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
2029 RETURN ( __MKSMALLINT(index - nInsts) ); |
2029 RETURN ( __MKSMALLINT(index - nInsts) ); |
2030 } |
2030 } |
2031 /* |
2031 /* |
2032 * send of #= could have lead to a GC - refetch e |
2032 * send of #= could have lead to a GC - refetch e |
2033 */ |
2033 */ |
2034 e = anElement; |
2034 e = anElement; |
2035 } |
2035 } |
2036 } |
2036 } |
2037 } |
2037 } |
2038 RETURN (__MKSMALLINT(0)); |
2038 RETURN (__MKSMALLINT(0)); |
2039 } |
2039 } |
2040 #endif |
2040 #endif |
2041 if (__isSmallInteger(e)) { |
2041 if (__isSmallInteger(e)) { |
2042 /* search for a small number */ |
2042 /* search for a small number */ |
2043 while (index < nIndex) { |
2043 while (index < nIndex) { |
2044 element = __InstPtr(self)->i_instvars[index++]; |
2044 element = __InstPtr(self)->i_instvars[index++]; |
2045 if (element == e) { |
2045 if (element == e) { |
2046 RETURN ( __MKSMALLINT(index - nInsts) ); |
2046 RETURN ( __MKSMALLINT(index - nInsts) ); |
2047 } |
2047 } |
2048 if (!__isSmallInteger(element)) { |
2048 if (!__isSmallInteger(element)) { |
2049 if ((*eq.ilc_func)(e, |
2049 if ((*eq.ilc_func)(e, |
2050 @symbol(=), |
2050 @symbol(=), |
2051 nil,&eq, |
2051 nil,&eq, |
2052 element) == true) { |
2052 element) == true) { |
2053 RETURN ( __MKSMALLINT(index - nInsts) ); |
2053 RETURN ( __MKSMALLINT(index - nInsts) ); |
2054 } |
2054 } |
2055 /* |
2055 /* |
2056 * send of #= could have lead to a GC - refetch e |
2056 * send of #= could have lead to a GC - refetch e |
2057 */ |
2057 */ |
2058 e = anElement; |
2058 e = anElement; |
2059 } |
2059 } |
2060 } |
2060 } |
2061 RETURN (__MKSMALLINT(0)); |
2061 RETURN (__MKSMALLINT(0)); |
2062 } |
2062 } |
2063 |
2063 |
2064 while (index < nIndex) { |
2064 while (index < nIndex) { |
2065 element = __InstPtr(self)->i_instvars[index++]; |
2065 element = __InstPtr(self)->i_instvars[index++]; |
2066 if (element != nil) { |
2066 if (element != nil) { |
2067 e = anElement; |
2067 e = anElement; |
2068 |
2068 |
2069 if ((element == e) |
2069 if ((element == e) |
2070 || ((*eq.ilc_func)(e, |
2070 || ((*eq.ilc_func)(e, |
2071 @symbol(=), |
2071 @symbol(=), |
2072 nil,&eq, |
2072 nil,&eq, |
2073 element) == true)) { |
2073 element) == true)) { |
2074 RETURN ( __MKSMALLINT(index - nInsts) ); |
2074 RETURN ( __MKSMALLINT(index - nInsts) ); |
2075 } |
2075 } |
2076 } |
2076 } |
2077 } |
2077 } |
2078 } else { |
2078 } else { |
2079 OBJ slf = self; |
2079 OBJ slf = self; |
2080 |
2080 |
2081 /* |
2081 /* |
2082 * search for nil - do an identity-search |
2082 * search for nil - do an identity-search |
2083 */ |
2083 */ |
2084 #if defined(UNROLL_LOOPS) |
2084 #if defined(UNROLL_LOOPS) |
2085 { |
2085 { |
2086 unsigned int i8; |
2086 unsigned int i8; |
2087 |
2087 |
2088 while ((i8 = index + 8) < nIndex) { |
2088 while ((i8 = index + 8) < nIndex) { |
2089 if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
2089 if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
2090 if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
2090 if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
2091 if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
2091 if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
2092 if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
2092 if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
2093 if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
2093 if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
2094 if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
2094 if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
2095 if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
2095 if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
2096 if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
2096 if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
2097 index = i8; |
2097 index = i8; |
2098 } |
2098 } |
2099 } |
2099 } |
2100 #endif |
2100 #endif |
2101 |
2101 |
2102 while (index < nIndex) { |
2102 while (index < nIndex) { |
2103 if (__InstPtr(slf)->i_instvars[index++] == nil) { |
2103 if (__InstPtr(slf)->i_instvars[index++] == nil) { |
2104 RETURN ( __MKSMALLINT(index - nInsts) ); |
2104 RETURN ( __MKSMALLINT(index - nInsts) ); |
2105 } |
2105 } |
2106 } |
2106 } |
2107 } |
2107 } |
2108 } |
2108 } |
2109 RETURN (__MKSMALLINT(0)); |
2109 RETURN (__MKSMALLINT(0)); |
2110 } |
2110 } |
2111 %}. |
2111 %}. |
2112 ^ super indexOf:anElement startingAt:start |
2112 ^ super indexOf:anElement startingAt:start |
2113 ! |
2113 ! |
2114 |
2114 |
2124 static struct inlineCache eq = _ILC1; |
2124 static struct inlineCache eq = _ILC1; |
2125 OBJ myClass, e; |
2125 OBJ myClass, e; |
2126 |
2126 |
2127 myClass = __qClass(self); |
2127 myClass = __qClass(self); |
2128 if ( __bothSmallInteger(start, stop) ) { |
2128 if ( __bothSmallInteger(start, stop) ) { |
2129 index = __intVal(start) - 1; |
2129 index = __intVal(start) - 1; |
2130 if (index >= 0) { |
2130 if (index >= 0) { |
2131 nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
2131 nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars); |
2132 index += nInsts; |
2132 index += nInsts; |
2133 lastIndex = nInsts + __intVal(stop); |
2133 lastIndex = nInsts + __intVal(stop); |
2134 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
2134 nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE); |
2135 if (nIndex < lastIndex) { |
2135 if (nIndex < lastIndex) { |
2136 lastIndex = nIndex; |
2136 lastIndex = nIndex; |
2137 } |
2137 } |
2138 |
2138 |
2139 e = anElement; |
2139 e = anElement; |
2140 |
2140 |
2141 if (e != nil) { |
2141 if (e != nil) { |
2142 /* |
2142 /* |
2143 * special kludge to search for a string; |
2143 * special kludge to search for a string; |
2144 * this is so common, that its worth a special case |
2144 * this is so common, that its worth a special case |
2145 */ |
2145 */ |
2146 #define SPECIAL_STRING_OPT |
2146 #define SPECIAL_STRING_OPT |
2147 #ifdef SPECIAL_STRING_OPT |
2147 #ifdef SPECIAL_STRING_OPT |
2148 if (__isString(e)) { |
2148 if (__isString(e)) { |
2149 while (index < lastIndex) { |
2149 while (index < lastIndex) { |
2150 element = __InstPtr(self)->i_instvars[index++]; |
2150 element = __InstPtr(self)->i_instvars[index++]; |
2151 if (__isNonNilObject(e)) { |
2151 if (__isNonNilObject(e)) { |
2152 if (element == e) { |
2152 if (element == e) { |
2153 RETURN ( __MKSMALLINT(index - nInsts) ); |
2153 RETURN ( __MKSMALLINT(index - nInsts) ); |
2154 } |
2154 } |
2155 if (__qClass(element) == @global(String)) { |
2155 if (__qClass(element) == @global(String)) { |
2156 if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
2156 if (strcmp(__stringVal(e), __stringVal(element)) == 0) { |
2157 RETURN ( __MKSMALLINT(index - nInsts) ); |
2157 RETURN ( __MKSMALLINT(index - nInsts) ); |
2158 } |
2158 } |
2159 } else { |
2159 } else { |
2160 if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
2160 if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) { |
2161 RETURN ( __MKSMALLINT(index - nInsts) ); |
2161 RETURN ( __MKSMALLINT(index - nInsts) ); |
2162 } |
2162 } |
2163 /* |
2163 /* |
2164 * send of #= could have lead to a GC - refetch e |
2164 * send of #= could have lead to a GC - refetch e |
2165 */ |
2165 */ |
2166 e = anElement; |
2166 e = anElement; |
2167 } |
2167 } |
2168 } |
2168 } |
2169 } |
2169 } |
2170 RETURN (__MKSMALLINT(0)); |
2170 RETURN (__MKSMALLINT(0)); |
2171 } |
2171 } |
2172 #endif |
2172 #endif |
2173 if (__isSmallInteger(e)) { |
2173 if (__isSmallInteger(e)) { |
2174 /* search for a small number */ |
2174 /* search for a small number */ |
2175 while (index < lastIndex) { |
2175 while (index < lastIndex) { |
2176 element = __InstPtr(self)->i_instvars[index++]; |
2176 element = __InstPtr(self)->i_instvars[index++]; |
2177 if (element == e) { |
2177 if (element == e) { |
2178 RETURN ( __MKSMALLINT(index - nInsts) ); |
2178 RETURN ( __MKSMALLINT(index - nInsts) ); |
2179 } |
2179 } |
2180 if (!__isSmallInteger(element)) { |
2180 if (!__isSmallInteger(element)) { |
2181 if ((*eq.ilc_func)(e, |
2181 if ((*eq.ilc_func)(e, |
2182 @symbol(=), |
2182 @symbol(=), |
2183 nil,&eq, |
2183 nil,&eq, |
2184 element) == true) { |
2184 element) == true) { |
2185 RETURN ( __MKSMALLINT(index - nInsts) ); |
2185 RETURN ( __MKSMALLINT(index - nInsts) ); |
2186 } |
2186 } |
2187 /* |
2187 /* |
2188 * send of #= could have lead to a GC - refetch e |
2188 * send of #= could have lead to a GC - refetch e |
2189 */ |
2189 */ |
2190 e = anElement; |
2190 e = anElement; |
2191 } |
2191 } |
2192 } |
2192 } |
2193 RETURN (__MKSMALLINT(0)); |
2193 RETURN (__MKSMALLINT(0)); |
2194 } |
2194 } |
2195 |
2195 |
2196 while (index < lastIndex) { |
2196 while (index < lastIndex) { |
2197 element = __InstPtr(self)->i_instvars[index++]; |
2197 element = __InstPtr(self)->i_instvars[index++]; |
2198 if (element != nil) { |
2198 if (element != nil) { |
2199 e = anElement; |
2199 e = anElement; |
2200 if ((element == e) |
2200 if ((element == e) |
2201 || ((*eq.ilc_func)(e, |
2201 || ((*eq.ilc_func)(e, |
2202 @symbol(=), |
2202 @symbol(=), |
2203 nil,&eq, |
2203 nil,&eq, |
2204 element) == true)) { |
2204 element) == true)) { |
2205 RETURN ( __MKSMALLINT(index - nInsts) ); |
2205 RETURN ( __MKSMALLINT(index - nInsts) ); |
2206 } |
2206 } |
2207 } |
2207 } |
2208 } |
2208 } |
2209 } else { |
2209 } else { |
2210 OBJ slf = self; |
2210 OBJ slf = self; |
2211 |
2211 |
2212 /* |
2212 /* |
2213 * search for nil - do an identity-search |
2213 * search for nil - do an identity-search |
2214 */ |
2214 */ |
2215 #if defined(UNROLL_LOOPS) |
2215 #if defined(UNROLL_LOOPS) |
2216 { |
2216 { |
2217 unsigned int i8; |
2217 unsigned int i8; |
2218 |
2218 |
2219 while ((i8 = index + 8) < lastIndex) { |
2219 while ((i8 = index + 8) < lastIndex) { |
2220 if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
2220 if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 1) ); } |
2221 if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
2221 if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 2) ); } |
2222 if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
2222 if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 3) ); } |
2223 if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
2223 if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 4) ); } |
2224 if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
2224 if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 5) ); } |
2225 if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
2225 if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 6) ); } |
2226 if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
2226 if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 7) ); } |
2227 if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
2227 if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __MKSMALLINT(index - nInsts + 8) ); } |
2228 index = i8; |
2228 index = i8; |
2229 } |
2229 } |
2230 } |
2230 } |
2231 #endif |
2231 #endif |
2232 while (index < lastIndex) { |
2232 while (index < lastIndex) { |
2233 if (__InstPtr(slf)->i_instvars[index++] == nil) { |
2233 if (__InstPtr(slf)->i_instvars[index++] == nil) { |
2234 RETURN ( __MKSMALLINT(index - nInsts) ); |
2234 RETURN ( __MKSMALLINT(index - nInsts) ); |
2235 } |
2235 } |
2236 } |
2236 } |
2237 } |
2237 } |
2238 } |
2238 } |
2239 RETURN (__MKSMALLINT(0)); |
2239 RETURN (__MKSMALLINT(0)); |
2240 } |
2240 } |
2241 %}. |
2241 %}. |
2242 ^ super indexOf:anElement startingAt:start endingAt:stop |
2242 ^ super indexOf:anElement startingAt:start endingAt:stop |
2243 ! ! |
2243 ! ! |
2244 |
2244 |