[squeak-dev] The Trunk: Collections-eem.1008.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Apr 26 00:52:01 UTC 2022


Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.1008.mcz

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

Name: Collections-eem.1008
Author: eem
Time: 25 April 2022, 5:51:59.387057 pm
UUID: 4f60759e-1496-45d0-9ca5-4905444e4676
Ancestors: Collections-ct.1006

Change beginsWith: and endsWith: to be true for the empty sequence, e.g. 'foo' beginsWith: '' is now true.  See http://lists.squeakfoundation.org/pipermail/squeak-dev/2022-April/220038.html

=============== Diff against Collections-ct.1006 ===============

Item was changed:
  ----- Method: SequenceableCollection>>beginsWith: (in category 'testing') -----
  beginsWith: sequence
+ 	"Answer if the receiver starts with the argument collection."
- 	"Answer true if the receiver starts with the argument collection."
  	
  	| sequenceSize |
+ 	sequenceSize := sequence size.
+ 	self size < sequenceSize ifTrue: [ ^false ].
- 	((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
  	1 to: sequenceSize do: [ :index |
  		(sequence at: index) = (self at: index) ifFalse: [ ^false ] ].
  	^true!

Item was changed:
  ----- Method: SequenceableCollection>>endsWith: (in category 'testing') -----
  endsWith: sequence
+ 	"Answer if the receiver ends with the argument collection."
- 	"Answer true if the receiver ends with the argument collection."
  	
  	| sequenceSize offset |
+ 	sequenceSize := sequence size.
+ 	(offset := self size - sequenceSize) < 0 ifTrue: [ ^false ].
- 	((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequence size) < 0 ]) ifTrue: [ ^false ].
  	1 to: sequenceSize do: [ :index |
  		(sequence at: index) = (self at: index + offset) ifFalse: [ ^false ] ].
  	^true!

Item was changed:
  ----- Method: String>>beginsWith: (in category 'testing') -----
  beginsWith: sequence
+ 	"Answer if the receiver starts with the argument collection. The comparison is case-sensitive. Overridden for better performance."
- 	"Answer true if the receiver starts with the argument collection. The comparison is case-sensitive. Overridden for better performance."
  
  	| index sequenceSize |
  	sequence isString ifFalse: [ ^super beginsWith: sequence ].
+ 	sequenceSize := sequence size.
+ 	self size < sequenceSize ifTrue: [ ^false ].
- 	((sequenceSize := sequence size) = 0 or: [ self size < sequenceSize ]) ifTrue: [ ^false ].
  	index := 0.
  	[ (index := index + 1) <= sequenceSize ] whileTrue: [
  		(sequence at: index) == (self at: index) ifFalse: [ ^false ] ].
  	^true!

Item was changed:
  ----- Method: String>>endsWith: (in category 'testing') -----
  endsWith: sequence
+ 	"Answer if the receiver ends with the argument collection. The comparison is case-sensitive."
- 	"Answer true if the receiver ends with the argument collection. The comparison is case-sensitive."
  	
  	| index sequenceSize offset |
  	sequence isString ifFalse: [ ^super endsWith: sequence ].
+ 	sequenceSize := sequence size.
- 	(sequenceSize := sequence size) = 0 ifTrue: [ ^false ]. "old convention"
  	(offset := self size - sequenceSize) < 0 ifTrue: [ ^false ].
  	index := 0.
  	[ (index := index + 1) <= sequenceSize ] whileTrue: [
  		(sequence at: index) == (self at: index + offset) ifFalse: [ ^false ] ].
  	^true!



More information about the Squeak-dev mailing list