[squeak-dev] The Inbox: Collections-eem.1007.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Apr 25 19:20:02 UTC 2022


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

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

Name: Collections-eem.1007
Author: eem
Time: 25 April 2022, 12:19:59.631943 pm
UUID: 6c5fbbd1-320d-44dd-b8d5-ff923f041cd6
Ancestors: Collections-ct.1006

Change beginsWith: and endsWith: to be true for the empty sequence, e.g. 'foo' beginsWith: '' is now true.

=============== 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 - sequence size) < 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