The Trunk: Collections-ul.625.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-ul.625.mcz

commits-2
Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.625.mcz

==================== Summary ====================

Name: Collections-ul.625
Author: ul
Time: 1 May 2015, 1:41:40.726 pm
UUID: d09538cd-53f4-42d7-8070-224fde4a4ae2
Ancestors: Collections-ul.624

Use the ClassificationTable in #asLowercase, #asUppercase (the obsolete behavior is gone), #isAlphaNumeric, #isDigit, #isLetter, #isLowercase and #isUppercase of Character.

=============== Diff against Collections-ul.624 ===============

Item was changed:
  ----- Method: Character>>asLowercase (in category 'converting') -----
  asLowercase
+ "Answer the receiver's matching lowercase Character."
+
+ value > 255 ifFalse: [
+ | result |
+ (result := (ClassificationTable at: value + 1) bitAnd: 16rFF) > 0
+ ifTrue: [ ^self class value: result ] ].
+ ^self class value: (self encodedCharSet toLowercaseCode: value)!
- "If the receiver is uppercase, answer its matching lowercase Character."
- "A tentative implementation.  Eventually this should consult the Unicode table."
-
- | v |
- v := self charCode.
- (((8r101 <= v and: [v <= 8r132]) or: [16rC0 <= v and: [v <= 16rD6]]) or: [16rD8 <= v and: [v <= 16rDE]])
- ifTrue: [^ Character value: v + 8r40].
- v < 256 ifTrue: [^self].
- ^self class value: ((value < 16r400000
- ifTrue: [Unicode]
- ifFalse: [self encodedCharSet charsetClass])
- toLowercaseCode: v)!

Item was changed:
  ----- Method: Character>>asUppercase (in category 'converting') -----
  asUppercase
+ "Answer the receiver's matching uppercase Character."
+
+ value > 255 ifFalse: [
+ | result |
+ (result := ((ClassificationTable at: value + 1) bitShift: -8) bitAnd: 16rFF) > 0
+ ifTrue: [ ^self class value: result ] ].
+ ^self class value: (self encodedCharSet toUppercaseCode: value)!
- "If the receiver is lowercase, answer its matching uppercase Character."
- "A tentative implementation.  Eventually this should consult the Unicode table."
-
- | v |
- v := self charCode.
- (((8r141 <= v and: [v <= 8r172]) or: [16rE0 <= v and: [v <= 16rF6]]) or: [16rF8 <= v and: [v <= 16rFE]])
- ifTrue: [^ Character value: v - 8r40].
- v < 256 ifTrue: [^self].
- ^self class value: ((value < 16r400000
- ifTrue: [Unicode]
- ifFalse: [self encodedCharSet charsetClass])
- toUppercaseCode: v)!

Item was changed:
  ----- Method: Character>>isAlphaNumeric (in category 'testing') -----
  isAlphaNumeric
  "Answer whether the receiver is a letter or a digit."
 
+ value > 255 ifFalse: [ ^((ClassificationTable at: value + 1) bitAnd: AlphaNumericMask) > 0 ].
  ^self encodedCharSet isAlphaNumeric: self!

Item was changed:
  ----- Method: Character>>isDigit (in category 'testing') -----
  isDigit
 
+ value > 255 ifFalse: [ ^((ClassificationTable at: value + 1) bitAnd: DigitBit) > 0 ].
  ^self encodedCharSet isDigit: self.
  !

Item was changed:
  ----- Method: Character>>isLetter (in category 'testing') -----
  isLetter
 
+ value > 255 ifFalse: [ ^((ClassificationTable at: value + 1) bitAnd: LetterMask) > 0 ].
+ ^self encodedCharSet isLetter: self!
- ^self encodedCharSet isLetter: self.
- !

Item was changed:
  ----- Method: Character>>isLowercase (in category 'testing') -----
  isLowercase
 
+ value > 255 ifFalse: [ ^((ClassificationTable at: value + 1) bitAnd: LowercaseBit) > 0 ].
  ^self encodedCharSet isLowercase: self.
  !

Item was changed:
  ----- Method: Character>>isUppercase (in category 'testing') -----
  isUppercase
 
+ value > 255 ifFalse: [ ^((ClassificationTable at: value + 1) bitAnd: UppercaseBit) > 0 ].
  ^self encodedCharSet isUppercase: self.
  !