The Trunk: Collections-nice.509.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-nice.509.mcz

commits-2
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.509.mcz

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

Name: Collections-nice.509
Author: nice
Time: 11 March 2013, 11:44:11.214 pm
UUID: 564cf9ab-5356-416f-b317-51d2c380ce0f
Ancestors: Collections-nice.508

Fix String>>numArgs: no an empty key in a keyword is not a valid pattern.

=============== Diff against Collections-nice.508 ===============

Item was changed:
  ----- Method: String>>numArgs (in category 'accessing') -----
  numArgs
  "Answer either the number of arguments that the receiver would take if considered a selector.  Answer -1 if it couldn't be a selector. It is intended mostly for the assistance of spelling correction."
 
  | firstChar numColons start ix |
  self size = 0 ifTrue: [ ^-1 ].
  firstChar := self at: 1.
  firstChar isSpecial ifTrue: [
  2 to: self size do: [ :i | (self at: i) isSpecial ifFalse: [ ^-1 ] ].
  ^1 ].
  self canBeToken ifFalse: [ ^-1 ].
  "Fast colon count"
  numColons := 0.
  start := 1.
+ [firstChar isLetter ifFalse: [ ^-1 ].
- [(firstChar isLetter or: [firstChar = $:]) ifFalse: [ ^-1 ].
  (ix := self indexOf: $: startingAt: start) > 0 ] whileTrue: [
  numColons := numColons + 1.
  (start := ix + 1) > self size ifFalse: [firstChar := self at: start]].
  (numColons > 0 and: [ self last ~= $: ]) ifTrue: [ ^-1 ].
  ^numColons!