#BUGFIX by stefan
authorStefan Vogel <sv@exept.de>
Fri, 08 Jul 2016 01:04:22 +0200
changeset 20126 8341bd725f11
parent 20125 ae67288913e3
child 20127 9268d5186b15
child 20131 4118d61ddba0
#BUGFIX by stefan class: String changed: #asLowercase bad code in prev version
String.st
--- a/String.st	Thu Jul 07 20:22:12 2016 +0200
+++ b/String.st	Fri Jul 08 01:04:22 2016 +0200
@@ -522,6 +522,7 @@
 
 
 
+
 !String class methodsFor:'queries'!
 
 defaultPlatformClass
@@ -2466,43 +2467,33 @@
             // I.e. they have the 0x20 bit clear.
             // Thus, we can fast skip over lowercase, spaces and some punctuation,
             // 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 = *(unsigned INT *)(cp+i);
+                if ((eightChars & 0x2020202020202020ULL) != 0x2020202020202020ULL) goto convert;
+                *(unsigned INT *)(quickBuffer+i) = eightChars;
             }
 #endif
-            for (; i<(sz-4); i+=4) {
-                unsigned int fourChars;
-
-                fourChars = *((unsigned int *)(cp));
+            for (; i < (sz-4); i += 4) {
+                unsigned int fourChars = *(unsigned int *)(cp+i);
                 if ((fourChars & 0x20202020U) != 0x20202020U) break;
-                *((unsigned int *)(&quickBuffer[i])) = fourChars;
+                *(unsigned int *)(quickBuffer+i) = fourChars;
             }
-
+convert:
             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';
+                    if (ch >= 'A' && ch <= 'Z') {
+                        quickBuffer[i] = ch - 'A' + 'a';
+                        anyChange = 1;
+                    } else {
+                        // deal with national latin1 characters
+                        if (ch >= 0xC0 && ch <= 0xDE && ch != 0xD7) {
+                            quickBuffer[i] = ch + 0x20;
                             anyChange = 1;
-                        } else {
-                            // deal with national latin1 characters
-                            if (ch >= 0xC0) {
-                                if (ch <= 0xDE) {
-                                    if (ch != 0xD7) {
-                                        quickBuffer[i] = ch + 0x20;
-                                        anyChange = 1;
-                                    }
-                                }
-                            }
                         }
                     }
                 }
@@ -2520,6 +2511,7 @@
 
     "
         'Hello WORLD' asLowercase
+        (String new:300) asLowercase
     "
 !