--- a/String.st Wed Apr 29 06:39:38 2015 +0200
+++ b/String.st Thu Apr 30 07:07:24 2015 +0200
@@ -922,14 +922,24 @@
- reimplemented here for speed"
%{ /* NOCONTEXT */
-#undef __UNROLL_LOOPS__
-#undef FAST_MEMCHR
-#define V2
+#ifdef __SCHTEAM__
+ if (start.isSmallInteger()
+ && aCharacter.isSTCharacter()) {
+ int idx1Based = start.intValue(); // st index is 1 based
+ int jIdx = self.asString().indexOf(aCharacter.charValue(), idx1Based-1);
+
+ return context._RETURN( jIdx+1 ); // st index is 1 based
+ }
+
+#else
+# undef __UNROLL_LOOPS__
+# undef FAST_MEMCHR
+# define V2
REGISTER unsigned char *cp;
-#ifdef FAST_MEMCHR
+# ifdef FAST_MEMCHR
REGISTER unsigned char *ncp;
-#endif
+# endif
REGISTER INT index;
REGISTER unsigned byteValue;
int last;
@@ -950,13 +960,13 @@
last -= numInstBytes;
}
if (index <= last) {
-#ifdef FAST_MEMCHR
+# ifdef FAST_MEMCHR
ncp = (unsigned char *) memchr(cp+index-1, byteValue, last+1-index);
if (ncp) {
RETURN ( __mkSmallInteger(ncp - cp + 1) );
}
-#else
-# ifdef __UNROLL_LOOPS__
+# else
+# ifdef __UNROLL_LOOPS__
{
int last3 = last-3;
@@ -967,15 +977,15 @@
if (cp[index-1+3] == byteValue) { RETURN ( __mkSmallInteger(index+3) ); }
}
}
-# endif
-# ifdef V1
+# endif
+# ifdef V1
for (; index <= last; index++) {
if (cp[index-1] == byteValue) {
RETURN ( __mkSmallInteger(index) );
}
}
-# endif
-# ifdef V2
+# endif
+# ifdef V2
{
// see bit twiddling hacks
# define hasZeroByte(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
@@ -1000,15 +1010,16 @@
index++;
}
}
+# endif
# endif
-#endif
}
}
}
RETURN ( __mkSmallInteger(0) );
}
}
-#undef V2
+# undef V2
+#endif /* not SCHTEAM */
%}.
^ super indexOf:aCharacter startingAt:start
@@ -4310,9 +4321,9 @@
!String class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.336 2015-04-26 11:18:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.337 2015-04-29 11:22:57 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.336 2015-04-26 11:18:39 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.337 2015-04-29 11:22:57 cg Exp $'
! !