--- a/String.st Wed Dec 23 07:03:27 2015 +0100
+++ b/String.st Sat Dec 26 08:45:38 2015 +0100
@@ -503,7 +503,6 @@
! !
-
!String class methodsFor:'queries'!
defaultPlatformClass
@@ -524,9 +523,6 @@
! !
-
-
-
!String methodsFor:'Compatibility-VW5.4'!
asByteString
@@ -546,7 +542,6 @@
"Modified: / 12-01-2011 / 12:33:58 / cg"
! !
-
!String methodsFor:'accessing'!
at:index
@@ -925,10 +920,10 @@
#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
+ 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
@@ -946,92 +941,92 @@
OBJ cls;
if (__isSmallInteger(start)) {
- index = __intVal(start);
- if (index > 0) {
- if (__isCharacter(aCharacter)) {
- byteValue = __intVal(__characterVal(aCharacter));
- if (byteValue <= 0xFF) {
- last = __stringSize(self);
- cp = __stringVal(self);
- if ((cls = __qClass(self)) != String) {
- int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-
- cp += numInstBytes;
- last -= numInstBytes;
- }
- if (index <= last) {
+ index = __intVal(start);
+ if (index > 0) {
+ if (__isCharacter(aCharacter)) {
+ byteValue = __intVal(__characterVal(aCharacter));
+ if (byteValue <= 0xFF) {
+ last = __stringSize(self);
+ cp = __stringVal(self);
+ if ((cls = __qClass(self)) != String) {
+ int numInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
+
+ cp += numInstBytes;
+ last -= numInstBytes;
+ }
+ if (index <= last) {
# ifdef FAST_MEMCHR
- ncp = (unsigned char *) memchr(cp+index-1, byteValue, last+1-index);
- if (ncp) {
- RETURN ( __mkSmallInteger(ncp - cp + 1) );
- }
+ ncp = (unsigned char *) memchr(cp+index-1, byteValue, last+1-index);
+ if (ncp) {
+ RETURN ( __mkSmallInteger(ncp - cp + 1) );
+ }
# else
# ifdef __UNROLL_LOOPS__
- {
- int last3 = last-3;
-
- for (; index <= last3; index += 4) {
- if (cp[index-1] == byteValue) { RETURN ( __mkSmallInteger(index) ); }
- if (cp[index-1+1] == byteValue) { RETURN ( __mkSmallInteger(index+1) ); }
- if (cp[index-1+2] == byteValue) { RETURN ( __mkSmallInteger(index+2) ); }
- if (cp[index-1+3] == byteValue) { RETURN ( __mkSmallInteger(index+3) ); }
- }
- }
+ {
+ int last3 = last-3;
+
+ for (; index <= last3; index += 4) {
+ if (cp[index-1] == byteValue) { RETURN ( __mkSmallInteger(index) ); }
+ if (cp[index-1+1] == byteValue) { RETURN ( __mkSmallInteger(index+1) ); }
+ if (cp[index-1+2] == byteValue) { RETURN ( __mkSmallInteger(index+2) ); }
+ if (cp[index-1+3] == byteValue) { RETURN ( __mkSmallInteger(index+3) ); }
+ }
+ }
# endif
# ifdef V1
- for (; index <= last; index++) {
- if (cp[index-1] == byteValue) {
- RETURN ( __mkSmallInteger(index) );
- }
- }
+ for (; index <= last; index++) {
+ if (cp[index-1] == byteValue) {
+ RETURN ( __mkSmallInteger(index) );
+ }
+ }
# endif
# ifdef V2
- {
- // see bit twiddling hacks
+ {
+ // see bit twiddling hacks
# define hasZeroByte(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
# define hasByteM(v,m) hasZeroByte( (v) ^ m)
# if __POINTER_SIZE__ == 8
# define hasZeroByte8(v) (((v) - 0x0101010101010101ULL) & ~(v) & 0x8080808080808080ULL)
# define hasByteM8(v,m) hasZeroByte8( (v) ^ m)
- // the following loop checks eight bytes at once
- if (((index-1) & 0x7) == 0) {
- int last8 = last-8;
+ // the following loop checks eight bytes at once
+ if (((index-1) & 0x7) == 0) {
+ int last8 = last-8;
INT m = (~0ULL/255 * (byteValue));
- while (index <= last8) {
- unsigned INT v = *(unsigned INT *)(cp+index-1);
-
- if (hasByteM8(v,m)) break;
- index += 8;
- }
- }
+ while (index <= last8) {
+ unsigned INT v = *(unsigned INT *)(cp+index-1);
+
+ if (hasByteM8(v,m)) break;
+ index += 8;
+ }
+ }
# endif
- // the following loop checks four bytes at once
- if (((index-1) & 0x3) == 0) {
- int last4 = last-4;
- int m = (~0UL/255 * (byteValue));
-
- while (index <= last4) {
- unsigned int v = *(unsigned int *)(cp+index-1);
-
- if (hasByteM(v,m)) break;
- index += 4;
- }
- }
- while (index <= last) {
- if (cp[index-1] == byteValue) {
- RETURN ( __mkSmallInteger(index) );
- }
- index++;
- }
- }
+ // the following loop checks four bytes at once
+ if (((index-1) & 0x3) == 0) {
+ int last4 = last-4;
+ int m = (~0UL/255 * (byteValue));
+
+ while (index <= last4) {
+ unsigned int v = *(unsigned int *)(cp+index-1);
+
+ if (hasByteM(v,m)) break;
+ index += 4;
+ }
+ }
+ while (index <= last) {
+ if (cp[index-1] == byteValue) {
+ RETURN ( __mkSmallInteger(index) );
+ }
+ index++;
+ }
+ }
# endif
# endif
- }
- }
- }
- RETURN ( __mkSmallInteger(0) );
- }
+ }
+ }
+ }
+ RETURN ( __mkSmallInteger(0) );
+ }
}
# undef V2
#endif /* not SCHTEAM */
@@ -1134,14 +1129,14 @@
s atAllPut:$a.
s at:512 put:(Character space).
Time millisecondsToRun:[
- 1000000 timesRepeat:[ s indexOf:(Character space) ]
+ 1000000 timesRepeat:[ s indexOf:(Character space) ]
]
timing (ms):
- v1: 1763 normal
- 2340 +unroll
- 3308 memsrch !!
- v2: 1045
+ v1: 1763 normal
+ 2340 +unroll
+ 3308 memsrch !!
+ v2: 1045
"
"Modified: / 10-01-2012 / 17:09:34 / cg"
@@ -2317,67 +2312,67 @@
REGISTER OBJ slf = self;
if (__qClass(slf) == String) {
- char quickBuffer[256];
- int sz = __stringSize(slf);
-
- if (sz < (sizeof(quickBuffer)-1)) {
- REGISTER int i = 0;
- int anyChange = 0;
- REGISTER unsigned char *cp = __stringVal(slf);
-
- // fast advance
- // all uppercase chars are in the ranges 0x41 .. 0x5A (A..Z)
- // or 0xC0 .. 0xDF.
- // I.e. they have the 0x20 bit clear.
- // Thus, we can fast skip over lowercase, spaces and some puctuation,
- // if all bytes of a word have the x20 bit set.
- //
+ char quickBuffer[256];
+ int sz = __stringSize(slf);
+
+ if (sz < (sizeof(quickBuffer)-1)) {
+ REGISTER int i = 0;
+ int anyChange = 0;
+ REGISTER unsigned char *cp = __stringVal(slf);
+
+ // fast advance
+ // all uppercase chars are in the ranges 0x41 .. 0x5A (A..Z)
+ // or 0xC0 .. 0xDF.
+ // I.e. they have the 0x20 bit clear.
+ // Thus, we can fast skip over lowercase, spaces and some puctuation,
+ // if all bytes of a word have the x20 bit set.
+ //
#if __POINTER_SIZE__ == 8
- for (; i<(sz-8); i+=8) {
- unsigned INT eightChars;
-
- eightChars = *((unsigned INT *)(cp));
- if ((eightChars & 0x2020202020202020ULL) != 0x2020202020202020ULL) break;
- *((unsigned INT *)(&quickBuffer[i])) = eightChars;
- }
+ for (; i<(sz-8); i+=8) {
+ unsigned INT eightChars;
+
+ eightChars = *((unsigned INT *)(cp));
+ if ((eightChars & 0x2020202020202020ULL) != 0x2020202020202020ULL) break;
+ *((unsigned INT *)(&quickBuffer[i])) = eightChars;
+ }
#endif
- for (; i<(sz-4); i+=4) {
- unsigned int fourChars;
-
- fourChars = *((unsigned int *)(cp));
- if ((fourChars & 0x20202020U) != 0x20202020U) break;
- *((unsigned int *)(&quickBuffer[i])) = fourChars;
- }
-
- for (; i<sz; i++) {
- unsigned char ch = cp[i];
-
- quickBuffer[i] = ch;
- if ((ch & 0x60) == 0x40) {
- if (ch >= 'A') {
- if (ch <= 'Z') {
- quickBuffer[i] = ch - 'A' + 'a';
- anyChange = 1;
- } else {
- // deal with national latin1 characters
- if (ch >= 0xC0) {
- if (ch <= 0xDE) {
- if (ch != 0xD7) {
- quickBuffer[i] = ch + 0x20;
- anyChange = 1;
- }
- }
- }
- }
- }
- }
- }
- quickBuffer[i] = '\0';
- if (! anyChange) {
- RETURN(slf);
- }
- RETURN (__MKSTRING_L(quickBuffer, i));
- }
+ for (; i<(sz-4); i+=4) {
+ unsigned int fourChars;
+
+ fourChars = *((unsigned int *)(cp));
+ if ((fourChars & 0x20202020U) != 0x20202020U) break;
+ *((unsigned int *)(&quickBuffer[i])) = fourChars;
+ }
+
+ for (; i<sz; i++) {
+ unsigned char ch = cp[i];
+
+ quickBuffer[i] = ch;
+ if ((ch & 0x60) == 0x40) {
+ if (ch >= 'A') {
+ if (ch <= 'Z') {
+ quickBuffer[i] = ch - 'A' + 'a';
+ anyChange = 1;
+ } else {
+ // deal with national latin1 characters
+ if (ch >= 0xC0) {
+ if (ch <= 0xDE) {
+ if (ch != 0xD7) {
+ quickBuffer[i] = ch + 0x20;
+ anyChange = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ quickBuffer[i] = '\0';
+ if (! anyChange) {
+ RETURN(slf);
+ }
+ RETURN (__MKSTRING_L(quickBuffer, i));
+ }
}
#endif /* ! __SCHTEAM__ */
#endif
@@ -3558,7 +3553,7 @@
#ifdef __SCHTEAM__
if (@global(Stderr) == STObject.Nil) {
if (self.isStringLike()) {
- System.err.print(self.asString());
+ org.exept.stj.STSystem.err.print(self.asString());
return context._RETURN(self);
}
}
@@ -3594,7 +3589,7 @@
#ifdef __SCHTEAM__
if (@global(Stderr) == STObject.Nil) {
if (self.isStringLike()) {
- System.err.println(self.asString());
+ org.exept.stj.STSystem.err.println(self.asString());
return context._RETURN(self);
}
}
@@ -3622,7 +3617,7 @@
%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
if (STSmalltalkEnvironment.GetBindingOrNull(STSymbol._new("Stdout")) == null) {
- System.out.print(self.toString());
+ org.exept.stj.STSystem.out.print(self.toString());
return context._RETURN(self);
}
#else
@@ -3649,7 +3644,7 @@
%{ /* NOCONTEXT */
#ifdef __SCHTEAM__
if (STSmalltalkEnvironment.GetBindingOrNull(STSymbol._new("Stdout")) == null) {
- System.out.println(self.toString());
+ org.exept.stj.STSystem.out.println(self.toString());
return context._RETURN(self);
}
#else
@@ -3990,7 +3985,6 @@
^ super reverse
! !
-
!String methodsFor:'substring searching'!
indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
@@ -4502,7 +4496,6 @@
! !
-
!String class methodsFor:'documentation'!
version
@@ -4512,4 +4505,3 @@
version_CVS
^ '$Header$'
! !
-