[squeak-dev] The Inbox: Collections-tonyg.733.1.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 23 19:44:36 UTC 2017


A new version of Collections was added to project The Inbox:
http://source.squeak.org/inbox/Collections-tonyg.733.1.mcz

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

Name: Collections-tonyg.733.1
Author: tonyg
Time: 23 February 2017, 2:44:28.751184 pm
UUID: e754e6ad-dd14-4e97-8ec1-82422b8feaa5
Ancestors: Collections-topa.733

Allow zero and negative startingAt indices in SequenceableCollection>>#indexOfSubCollection:startingAt:ifAbsent:, for compatibility with the existing implementation in String. Fixes tests in CollectionsTests-tonyg.275 and NetworkTests-tonyg.44.

=============== Diff against Collections-topa.733 ===============

Item was changed:
  ----- Method: SequenceableCollection>>indexOfSubCollection:startingAt:ifAbsent: (in category 'accessing') -----
  indexOfSubCollection: sub startingAt: start ifAbsent: exceptionBlock
  	"Answer the index of the receiver's first element, such that that element 
  	equals the first element of sub, and the next elements equal 
  	the rest of the elements of sub. Begin the search at element 
  	start of the receiver. If no such match is found, answer the result of 
  	evaluating argument, exceptionBlock."
  	| first index |
  	sub isEmpty ifTrue: [^ exceptionBlock value].
  	first := sub first.
+ 	(start max: 1) to: self size - sub size + 1 do:
- 	start to: self size - sub size + 1 do:
  		[:startIndex |
  		(self at: startIndex) = first ifTrue:
  			[index := 1.
  			[(self at: startIndex+index-1) = (sub at: index)]
  				whileTrue:
  				[index = sub size ifTrue: [^startIndex].
  				index := index+1]]].
  	^ exceptionBlock value!



More information about the Squeak-dev mailing list