[squeak-dev] The Trunk: Collections-nice.320.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 25 23:58:15 UTC 2010


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

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

Name: Collections-nice.320
Author: nice
Time: 26 February 2010, 12:58:09.834 am
UUID: 5736e518-e074-104f-9b5e-75c544d37e3b
Ancestors: Collections-nice.319

Let findAnySubStr:startingAt: use inject:into:
Minor speed up, better code, no outer temp assignment

=============== Diff against Collections-nice.319 ===============

Item was changed:
  ----- Method: String>>findAnySubStr:startingAt: (in category 'accessing') -----
  findAnySubStr: delimiters startingAt: start 
  	"Answer the index of the character within the receiver, starting at start, that begins a substring matching one of the delimiters.  delimiters is an Array of Strings (Characters are permitted also).  If the receiver does not contain any of the delimiters, answer size + 1."
  
+ 	^delimiters inject: 1 + self size into: [:min :delim |
+ 		"delim may be a char, a string of length 1, or a substring"
+ 		| ind |
+ 		ind := delim isCharacter 
+ 			ifTrue: [self indexOf: delim
- 	| min |
- 	min := self size + 1.
- 	delimiters do: [:delim | | ind |	"May be a char, a string of length 1, or a substring"
- 		delim isCharacter 
- 			ifTrue: [ind := self indexOfSubCollection: (String with: delim) 
  						startingAt: start ifAbsent: [min]]
+ 			ifFalse: [self indexOfSubCollection: delim 
- 			ifFalse: [ind := self indexOfSubCollection: delim 
  						startingAt: start ifAbsent: [min]].
+ 		min min: ind]!
- 			min := min min: ind].
- 	^ min!




More information about the Squeak-dev mailing list