The Trunk: Collections-mt.625.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-mt.625.mcz

commits-2
Marcel Taeumel uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-mt.625.mcz

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

Name: Collections-mt.625
Author: mt
Time: 1 May 2015, 5:56:35.941 pm
UUID: 0edce141-a23a-a845-a735-743f311112b2
Ancestors: Collections-tfel.624

Speed-up #endsWith: for strings.

=============== Diff against Collections-tfel.624 ===============

Item was changed:
  ----- Method: String>>endsWith: (in category 'testing') -----
+ endsWith: sequence
+ "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive."
- endsWith: suffix
- "Answer true if the receiver ends with the argument collection. The comparison is case-sensitive. Overridden for better performance."
 
+ | sequenceSize offset |
+ sequence isString ifFalse: [ ^ super endsWith: sequence ].
+ ((sequenceSize := sequence size) = 0 or: [ (offset := self size - sequence size) < 0 ]) ifTrue: [ ^false ].
+ 1 to: sequenceSize do: [ :index |
+ (sequence basicAt: index) = (self basicAt: index + offset) ifFalse: [ ^false ] ].
+ ^true!
- | offset |
- (offset := self size - suffix size) < 0 ifTrue: [ ^false ].
- ^(self findString: suffix startingAt: offset + 1) ~= 0!