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

commits at source.squeak.org commits at source.squeak.org
Sat Oct 3 19:45:45 UTC 2009


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

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

Name: Collections-nice.152
Author: nice
Time: 3 October 2009, 9:45:06 am
UUID: 3a9d8bc0-dc5d-4cad-84f8-1d80fb850b4c
Ancestors: Collections-nice.151

Fix bug http://bugs.squeak.org/view.php?id=5331
beginsWith: did not work with a WideString receiver/argument

Solution is to use super beginsWith: rather than fast primitive, except if both receiver and argument are bytes....

=============== Diff against Collections-nice.151 ===============

Item was added:
+ ----- Method: ByteString>>beginsWith: (in category 'comparing') -----
+ beginsWith: prefix
+ 	"Answer whether the receiver begins with the given prefix string.
+ 	The comparison is case-sensitive."
+ 
+ 
+ 	"IMPLEMENTATION NOTE:
+ 	following algorithm is optimized in primitive only in case self and prefix are bytes like.
+ 	Otherwise, if self is wide, then super outperforms,
+ 	Otherwise, if prefix is wide, primitive is not correct"
+ 	
+ 	prefix class isBytes ifFalse: [^super beginsWith: prefix].
+ 	
+ 	self size < prefix size ifTrue: [^ false].
+ 	^ (self findSubstring: prefix in: self startingAt: 1
+ 			matchTable: CaseSensitiveOrder) = 1
+ !

Item was added:
+ ----- Method: ByteSymbol>>beginsWith: (in category 'comparing') -----
+ beginsWith: prefix
+ 	"Answer whether the receiver begins with the given prefix string.
+ 	The comparison is case-sensitive."
+ 
+ 
+ 	"IMPLEMENTATION NOTE:
+ 	following algorithm is optimized in primitive only in case self and prefix are bytes like.
+ 	Otherwise, if self is wide, then super outperforms,
+ 	Otherwise, if prefix is wide, primitive is not correct"
+ 	
+ 	prefix class isBytes ifFalse: [^super beginsWith: prefix].
+ 	
+ 	self size < prefix size ifTrue: [^ false].
+ 	^ (self findSubstring: prefix in: self startingAt: 1
+ 			matchTable: CaseSensitiveOrder) = 1
+ !

Item was removed:
- ----- Method: String>>beginsWith: (in category 'comparing') -----
- beginsWith: prefix
- 	"Answer whether the receiver begins with the given prefix string.
- 	The comparison is case-sensitive."
- 
- 	self size < prefix size ifTrue: [^ false].
- 	^ (self findSubstring: prefix in: self startingAt: 1
- 			matchTable: CaseSensitiveOrder) = 1
- !




More information about the Squeak-dev mailing list