[squeak-dev] The Trunk: Collections-ul.643.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Aug 20 23:17:52 UTC 2015


Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.643.mcz

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

Name: Collections-ul.643
Author: ul
Time: 20 August 2015, 9:08:27.692 pm
UUID: 12dbac56-4a90-45c3-8987-3ceb621a1c58
Ancestors: Collections-ul.642

String:
- reuse the code of #indexOf:startingAt: from #indexOf: and #indexOf:startingAt:ifAbsent: 

ByteArray:
- use the fast primitive for #indexOf:* the same way it is done in String

=============== Diff against Collections-ul.642 ===============

Item was added:
+ ----- Method: ByteArray>>indexOf: (in category 'accessing') -----
+ indexOf: anInteger
+ 
+ 	^self indexOf: anInteger startingAt: 1!

Item was changed:
  ----- Method: ByteArray>>indexOf:startingAt: (in category 'accessing') -----
  indexOf: anInteger startingAt: start
  
+ 	anInteger isInteger ifFalse: [ ^0 ].
+ 	0 <= anInteger ifFalse: [ ^0 ].
+ 	anInteger <= 255 ifFalse: [ ^0 ].
- 	(anInteger isInteger and: [
- 		anInteger >= 0 and: [
- 		anInteger <= 255 ] ]) ifFalse: [ ^0 ].
  	^ByteString indexOfAscii: anInteger inString: self startingAt: start!

Item was added:
+ ----- Method: ByteArray>>indexOf:startingAt:ifAbsent: (in category 'accessing') -----
+ indexOf: anInteger startingAt: start ifAbsent: aBlock
+ 
+ 	| index |
+ 	(index := self indexOf: anInteger startingAt: start) = 0 ifTrue: [ ^aBlock value ].
+ 	^index!

Item was changed:
  ----- Method: String>>indexOf: (in category 'accessing') -----
  indexOf: aCharacter
  
+ 	^self indexOf: aCharacter startingAt: 1
- 	aCharacter isCharacter ifFalse: [^ 0].
- 	^ self class
- 		indexOfAscii: aCharacter asciiValue
- 		inString: self
- 		startingAt: 1.
  !

Item was changed:
  ----- Method: String>>indexOf:startingAt:ifAbsent: (in category 'accessing') -----
  indexOf: aCharacter  startingAt: start  ifAbsent: aBlock
+ 
+ 	| index |
+ 	(index := self indexOf: aCharacter startingAt: start) = 0 ifTrue: [ ^aBlock value ].
+ 	^index!
- 	| ans |
- 	(aCharacter isCharacter) ifFalse: [ ^ aBlock value ].
- 	ans := self class indexOfAscii: aCharacter asciiValue inString: self  startingAt: start.
- 	ans = 0
- 		ifTrue: [ ^ aBlock value ]
- 		ifFalse: [ ^ ans ]!



More information about the Squeak-dev mailing list