String.st
changeset 20126 8341bd725f11
parent 20109 27a6eda44c02
child 20131 4118d61ddba0
child 20135 b9444b727175
equal deleted inserted replaced
20125:ae67288913e3 20126:8341bd725f11
   517     TAB isNil ifTrue:[
   517     TAB isNil ifTrue:[
   518 	TAB := String with:Character tab
   518 	TAB := String with:Character tab
   519     ].
   519     ].
   520     ^ TAB
   520     ^ TAB
   521 ! !
   521 ! !
       
   522 
   522 
   523 
   523 
   524 
   524 
   525 
   525 !String class methodsFor:'queries'!
   526 !String class methodsFor:'queries'!
   526 
   527 
  2464             // all uppercase chars are in the ranges 0x41 .. 0x5A (A..Z)
  2465             // all uppercase chars are in the ranges 0x41 .. 0x5A (A..Z)
  2465             // or 0xC0 .. 0xDF.
  2466             // or 0xC0 .. 0xDF.
  2466             // I.e. they have the 0x20 bit clear.
  2467             // I.e. they have the 0x20 bit clear.
  2467             // Thus, we can fast skip over lowercase, spaces and some punctuation,
  2468             // Thus, we can fast skip over lowercase, spaces and some punctuation,
  2468             // if all bytes of a word have the x20 bit set.
  2469             // if all bytes of a word have the x20 bit set.
  2469             //
  2470 
  2470 #if __POINTER_SIZE__ == 8
  2471 #if __POINTER_SIZE__ == 8
  2471             for (; i<(sz-8); i+=8) {
  2472             for (; i < (sz-8); i += 8) {
  2472                 unsigned INT eightChars;
  2473                 unsigned INT eightChars = *(unsigned INT *)(cp+i);
  2473 
  2474                 if ((eightChars & 0x2020202020202020ULL) != 0x2020202020202020ULL) goto convert;
  2474                 eightChars = *((unsigned INT *)(cp));
  2475                 *(unsigned INT *)(quickBuffer+i) = eightChars;
  2475                 if ((eightChars & 0x2020202020202020ULL) != 0x2020202020202020ULL) break;
       
  2476                 *((unsigned INT *)(&quickBuffer[i])) = eightChars;
       
  2477             }
  2476             }
  2478 #endif
  2477 #endif
  2479             for (; i<(sz-4); i+=4) {
  2478             for (; i < (sz-4); i += 4) {
  2480                 unsigned int fourChars;
  2479                 unsigned int fourChars = *(unsigned int *)(cp+i);
  2481 
       
  2482                 fourChars = *((unsigned int *)(cp));
       
  2483                 if ((fourChars & 0x20202020U) != 0x20202020U) break;
  2480                 if ((fourChars & 0x20202020U) != 0x20202020U) break;
  2484                 *((unsigned int *)(&quickBuffer[i])) = fourChars;
  2481                 *(unsigned int *)(quickBuffer+i) = fourChars;
  2485             }
  2482             }
  2486 
  2483 convert:
  2487             for (; i<sz; i++) {
  2484             for (; i<sz; i++) {
  2488                 unsigned char ch = cp[i];
  2485                 unsigned char ch = cp[i];
  2489 
  2486 
  2490                 quickBuffer[i] = ch;
  2487                 quickBuffer[i] = ch;
  2491                 if ((ch & 0x60) == 0x40) {
  2488                 if ((ch & 0x60) == 0x40) {
  2492                     if (ch >= 'A') {
  2489                     if (ch >= 'A' && ch <= 'Z') {
  2493                         if (ch <= 'Z') {
  2490                         quickBuffer[i] = ch - 'A' + 'a';
  2494                             quickBuffer[i] = ch - 'A' + 'a';
  2491                         anyChange = 1;
       
  2492                     } else {
       
  2493                         // deal with national latin1 characters
       
  2494                         if (ch >= 0xC0 && ch <= 0xDE && ch != 0xD7) {
       
  2495                             quickBuffer[i] = ch + 0x20;
  2495                             anyChange = 1;
  2496                             anyChange = 1;
  2496                         } else {
       
  2497                             // deal with national latin1 characters
       
  2498                             if (ch >= 0xC0) {
       
  2499                                 if (ch <= 0xDE) {
       
  2500                                     if (ch != 0xD7) {
       
  2501                                         quickBuffer[i] = ch + 0x20;
       
  2502                                         anyChange = 1;
       
  2503                                     }
       
  2504                                 }
       
  2505                             }
       
  2506                         }
  2497                         }
  2507                     }
  2498                     }
  2508                 }
  2499                 }
  2509             }
  2500             }
  2510             if (! anyChange) {
  2501             if (! anyChange) {
  2518 %}.
  2509 %}.
  2519     ^ super asLowercase
  2510     ^ super asLowercase
  2520 
  2511 
  2521     "
  2512     "
  2522         'Hello WORLD' asLowercase
  2513         'Hello WORLD' asLowercase
       
  2514         (String new:300) asLowercase
  2523     "
  2515     "
  2524 !
  2516 !
  2525 
  2517 
  2526 asPackageId
  2518 asPackageId
  2527     "given a package-string as receiver, return a packageId object.
  2519     "given a package-string as receiver, return a packageId object.