The Trunk: Collections-ul.742.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.742.mcz

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

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

Name: Collections-ul.742
Author: ul
Time: 13 March 2017, 3:48:27.984404 am
UUID: e13a7666-393a-49e3-ae8f-3fd24d09cb69
Ancestors: Collections-ul.741

- minor tweaks in String >> #alike: and Symbol class >> #hasInterned:ifTrue:

=============== Diff against Collections-ul.741 ===============

Item was changed:
  ----- Method: String>>alike: (in category 'comparing') -----
  alike: aString
  "Answer some indication of how alike the receiver is to the argument,  0 is no match, twice aString size is best score.  Case is ignored."
 
  | i j k minSize bonus |
  minSize := (j := self size) min: (k := aString size).
  bonus := (j - k) abs < 2 ifTrue: [ 1 ] ifFalse: [ 0 ].
  i := 1.
+ [(i <= minSize) and: [((self basicAt: i) bitAnd: 16rDF)  = ((aString basicAt: i) bitAnd: 16rDF)]]
- [(i <= minSize) and: [((super at: i) bitAnd: 16rDF)  = ((aString at: i) asciiValue bitAnd: 16rDF)]]
  whileTrue: [ i := i + 1 ].
  [(j > 0) and: [(k > 0) and:
+ [((self basicAt: j) bitAnd: 16rDF) = ((aString basicAt: k) bitAnd: 16rDF)]]]
- [((super at: j) bitAnd: 16rDF) = ((aString at: k) asciiValue bitAnd: 16rDF)]]]
  whileTrue: [ j := j - 1.  k := k - 1. ].
  ^ i - 1 + self size - j + bonus. !

Item was changed:
  ----- Method: Symbol class>>hasInterned:ifTrue: (in category 'private') -----
  hasInterned: aString ifTrue: symBlock
  "Answer with false if aString hasnt been interned (into a Symbol),  
  otherwise supply the symbol to symBlock and return true."
 
+ (self lookup: aString)
+ ifNil: [ ^false ]
+ ifNotNil: [ :symbol |
+ symBlock value: symbol.
+ ^true ]!
- | symbol |
- ^ (symbol := self lookup: aString)
- ifNil: [false]
- ifNotNil: [symBlock value: symbol.
- true]!