--- a/Array.st Tue Sep 18 14:58:52 2018 +0200
+++ b/Array.st Tue Sep 18 15:08:47 2018 +0200
@@ -2243,123 +2243,125 @@
myClass = __qClass(self);
if ( __isSmallInteger(start) ) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
-
- e = anElement;
- if (e != nil) {
- /*
- * special kludge to search for a string;
- * this is so common, that its worth a special case
- */
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+
+ e = anElement;
+ if (e != nil) {
+ /*
+ * special kludge to search for a string;
+ * this is so common, that its worth a special case
+ */
#define SPECIAL_STRING_OPT
#ifdef SPECIAL_STRING_OPT
- if (__isStringLike(e)) {
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(element)) {
- if (element == e) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- }
- RETURN (__mkSmallInteger(0));
- }
+ if (__isStringLike(e)) {
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(element)) {
+ if (element == e) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ if (__isStringLike(element)) {
+ if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ }
+ RETURN (__mkSmallInteger(0));
+ }
#endif
#ifdef MAKES_IT_SLOWER_BUT_WHY
- if (__isSmallInteger(e)) {
- /* search for a small number */
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element == e) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- if (!__isSmallInteger(element)) {
- if (element != nil) {
- if ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- }
- RETURN (__mkSmallInteger(0));
- }
+ if (__isSmallInteger(e)) {
+ /* search for a small number */
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element == e) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ if (!__isSmallInteger(element)) {
+ if (element != nil) {
+ if ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ }
+ RETURN (__mkSmallInteger(0));
+ }
#endif /* MAKES_IT_SLOWER_BUT_WHY */
- while (index < nIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- if ((element == e)
- || ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- } else {
- OBJ slf = self;
-
- /*
- * search for nil - do an identity-search
- */
+ while (index < nIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ if ((element == e)
+ || ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ } else {
+ OBJ slf = self;
+
+ /*
+ * search for nil - do an identity-search
+ */
#ifdef __UNROLL_LOOPS__
- {
- unsigned INT i8;
-
- while ((i8 = index + 8) < nIndex) {
- if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
- if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
- if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
- if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
- if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
- if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
- if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
- if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ {
+ unsigned INT i8;
+
+ while ((i8 = index + 8) < nIndex) {
+ if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
+ if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
+ if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
+ if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
+ if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
+ if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
+ if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
+ if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < nIndex) {
- if (__InstPtr(slf)->i_instvars[index++] == nil) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- }
- }
- }
- RETURN (__mkSmallInteger(0));
+ while (index < nIndex) {
+ if (__InstPtr(slf)->i_instvars[index++] == nil) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__mkSmallInteger(0));
}
%}.
^ super indexOf:anElement startingAt:start
+
+ "Modified: / 18-09-2018 / 15:02:21 / Stefan Vogel"
!
indexOf:anElement startingAt:start endingAt:stop
@@ -2377,120 +2379,122 @@
myClass = __qClass(self);
if ( __bothSmallInteger(start, stop) ) {
- index = __intVal(start) - 1;
- if (index >= 0) {
- nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
- index += nInsts;
- lastIndex = nInsts + __intVal(stop);
- nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
- if (nIndex < lastIndex) {
- lastIndex = nIndex;
- }
-
- e = anElement;
-
- if (e != nil) {
- /*
- * special kludge to search for a string;
- * this is so common, that its worth a special case
- */
+ index = __intVal(start) - 1;
+ if (index >= 0) {
+ nInsts = __intVal(__ClassInstPtr(myClass)->c_ninstvars);
+ index += nInsts;
+ lastIndex = nInsts + __intVal(stop);
+ nIndex = __BYTES2OBJS__(__qSize(self) - OHDR_SIZE);
+ if (nIndex < lastIndex) {
+ lastIndex = nIndex;
+ }
+
+ e = anElement;
+
+ if (e != nil) {
+ /*
+ * special kludge to search for a string;
+ * this is so common, that its worth a special case
+ */
#define SPECIAL_STRING_OPT
#ifdef SPECIAL_STRING_OPT
- if (__isStringLike(e)) {
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (__isNonNilObject(element)) {
- if (element == e) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- if (__qClass(element) == @global(String)) {
- if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- } else {
- if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- }
- RETURN (__mkSmallInteger(0));
- }
+ if (__isStringLike(e)) {
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (__isNonNilObject(element)) {
+ if (element == e) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ if (__isStringLike(element)) {
+ if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ } else {
+ if ((*eq.ilc_func)(e, @symbol(=), nil,&eq, element) == true) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ }
+ RETURN (__mkSmallInteger(0));
+ }
#endif
- if (__isSmallInteger(e)) {
- /* search for a small number */
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element == e) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- if (!__isSmallInteger(element)) {
- if ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- /*
- * send of #= could have lead to a GC - refetch e
- */
- e = anElement;
- }
- }
- RETURN (__mkSmallInteger(0));
- }
-
- while (index < lastIndex) {
- element = __InstPtr(self)->i_instvars[index++];
- if (element != nil) {
- e = anElement;
- if ((element == e)
- || ((*eq.ilc_func)(e,
- @symbol(=),
- nil,&eq,
- element) == true)) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- }
- }
- } else {
- OBJ slf = self;
-
- /*
- * search for nil - do an identity-search
- */
+ if (__isSmallInteger(e)) {
+ /* search for a small number */
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element == e) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ if (!__isSmallInteger(element)) {
+ if ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ /*
+ * send of #= could have lead to a GC - refetch e
+ */
+ e = anElement;
+ }
+ }
+ RETURN (__mkSmallInteger(0));
+ }
+
+ while (index < lastIndex) {
+ element = __InstPtr(self)->i_instvars[index++];
+ if (element != nil) {
+ e = anElement;
+ if ((element == e)
+ || ((*eq.ilc_func)(e,
+ @symbol(=),
+ nil,&eq,
+ element) == true)) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ }
+ }
+ } else {
+ OBJ slf = self;
+
+ /*
+ * search for nil - do an identity-search
+ */
#ifdef __UNROLL_LOOPS__
- {
- unsigned INT i8;
-
- while ((i8 = index + 8) < lastIndex) {
- if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
- if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
- if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
- if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
- if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
- if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
- if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
- if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
- index = i8;
- }
- }
+ {
+ unsigned INT i8;
+
+ while ((i8 = index + 8) < lastIndex) {
+ if (__InstPtr(slf)->i_instvars[index] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 1) ); }
+ if (__InstPtr(slf)->i_instvars[index+1] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 2) ); }
+ if (__InstPtr(slf)->i_instvars[index+2] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 3) ); }
+ if (__InstPtr(slf)->i_instvars[index+3] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 4) ); }
+ if (__InstPtr(slf)->i_instvars[index+4] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 5) ); }
+ if (__InstPtr(slf)->i_instvars[index+5] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 6) ); }
+ if (__InstPtr(slf)->i_instvars[index+6] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 7) ); }
+ if (__InstPtr(slf)->i_instvars[index+7] == nil) { RETURN ( __mkSmallInteger(index - nInsts + 8) ); }
+ index = i8;
+ }
+ }
#endif
- while (index < lastIndex) {
- if (__InstPtr(slf)->i_instvars[index++] == nil) {
- RETURN ( __mkSmallInteger(index - nInsts) );
- }
- }
- }
- }
- RETURN (__mkSmallInteger(0));
+ while (index < lastIndex) {
+ if (__InstPtr(slf)->i_instvars[index++] == nil) {
+ RETURN ( __mkSmallInteger(index - nInsts) );
+ }
+ }
+ }
+ }
+ RETURN (__mkSmallInteger(0));
}
%}.
^ super indexOf:anElement startingAt:start endingAt:stop
+
+ "Modified: / 18-09-2018 / 15:02:02 / Stefan Vogel"
!
indexOf:anElement startingAt:start step:stepArg
@@ -2527,7 +2531,7 @@
if (element == e) {
RETURN ( __mkSmallInteger(index+1 - nInsts) );
}
- if (__qClass(element) == @global(String)) {
+ if (__isStringLike(element)) {
if (strcmp(__stringVal(e), __stringVal(element)) == 0) {
RETURN ( __mkSmallInteger(index+1 - nInsts) );
}
@@ -2585,6 +2589,7 @@
#(1 2 3 4 5 6 7) indexOf:6 startingAt:1 step:2
#(1 2 3 4 5 6 bla) indexOf:#bla startingAt:1 step:2
#(1 2 3 4 5 6 'bla') indexOf:'bla' startingAt:1 step:2
+ #(1 2 3 4 5 6 'bla') indexOf:#bla startingAt:1 step:2
"
"Created: / 18-09-2018 / 14:05:53 / Stefan Vogel"