[squeak-dev] The Trunk: Collections-ar.134.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Sep 17 03:24:01 UTC 2009


Andreas Raab uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ar.134.mcz

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

Name: Collections-ar.134
Author: ar
Time: 16 September 2009, 8:23:39 am
UUID: 73ccbb29-90d4-9e41-bdad-6f3166c2216a
Ancestors: Collections-nice.133, Collections-ul.130

Merging Collections-ul.130:

- don't try to use the matchTable if it doesn't contain the character of the strings in String >> #findSubstring:in:startingAt:matchTable:

=============== Diff against Collections-nice.133 ===============

Item was changed:
  ----- Method: String>>findSubstring:in:startingAt:matchTable: (in category 'system primitives') -----
  findSubstring: key in: body startingAt: start matchTable: matchTable
  	"Answer the index in the string body at which the substring key first occurs, at or beyond start.  The match is determined using matchTable, which can be used to effect, eg, case-insensitive matches.  If no match is found, zero will be returned."
  	| index c1 c2 |
  	matchTable == nil ifTrue: [
  		key size = 0 ifTrue: [^ 0].
  		start to: body size - key size + 1 do:
  			[:startIndex |
  			index := 1.
  				[(body at: startIndex+index-1)
  					= (key at: index)]
  					whileTrue:
  					[index = key size ifTrue: [^ startIndex].
  					index := index+1]].
  		^ 0
  	].
  
  	key size = 0 ifTrue: [^ 0].
  	start to: body size - key size + 1 do:
  		[:startIndex |
  		index := 1.
  		[c1 := body at: startIndex+index-1.
  		c2 := key at: index.
+ 		((c1 leadingChar = 0 and: [ c1 asciiValue < matchTable size ]) 
+ 			ifTrue: [ matchTable at: c1 asciiValue + 1 ]
+ 			ifFalse: [ c1 asciiValue + 1 ]) = 
+ 			((c2 leadingChar = 0 and: [ c2 asciiValue < matchTable size ])
+ 				ifTrue: [ matchTable at: c2 asciiValue + 1 ]
+ 				ifFalse: [c2 asciiValue + 1 ]) ]
- 		((c1 leadingChar = 0) ifTrue: [(matchTable at: c1 asciiValue + 1)]
- 						ifFalse: [c1 asciiValue + 1])
- 			= ((c2 leadingChar = 0) ifTrue: [(matchTable at: c2 asciiValue + 1)]
- 								ifFalse: [c2 asciiValue + 1])]
  			whileTrue:
  				[index = key size ifTrue: [^ startIndex].
  				index := index+1]].
+ 	^ 0!
- 	^ 0
- !




More information about the Squeak-dev mailing list