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

Levente Uzonyi leves at caesar.elte.hu
Sat Feb 25 22:30:59 UTC 2017


Hi Eliot,

#caseOf:otherwise: seems quicker than the array lookup. The version I just 
pushed to the Trunk (Collections-ul.735) is faster for all characters 
between 0 and 32 ascii value on my current VM 
(cog_linux64x64_squeak.cog.spur_201702211732).
The comments were wrong, because I had reordered the branches to make it 
optimal for Squeak's source code format and forgot to swap the comments 
too.

Levente

On Fri, 24 Feb 2017, commits at source.squeak.org wrote:

> Eliot Miranda uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-eem.734.mcz
>
> ==================== Summary ====================
>
> Name: Collections-eem.734
> Author: eem
> Time: 24 February 2017, 3:51:29.783168 pm
> UUID: a81dce52-1da2-4c87-b8a7-fd6bf485396b
> Ancestors: Collections-topa.733
>
> Eliminate the ugly hack to speed up stream wide character writes.  The trade-offs with Spur have changed and the cure is now arguably worse than the disease.  The VM no longer supports the primitive (since it cannot be sufficiently polymorphic).  hence the hack is paid for on every write but pays off only on wide chaacter writes to byte strings.  Now that Spur's become is much faster than V3 let's accept that the writing of a wide character to a byte string stream won't be as fast, since all other stream writes will be.
>
> Slightly faster (and correctly commented) version of isSeparator.
>
> =============== Diff against Collections-topa.733 ===============
>
> Item was changed:
>  ----- Method: Character>>isSeparator (in category 'testing') -----
>  isSeparator
>  	"Answer whether the receiver is one of the separator characters--space,
>  	cr, tab, line feed, or form feed."
>
>  	| integerValue |
> + 	(integerValue := self asInteger) > 32 ifTrue: [^false].
> + 	^#(false false false false false false false false false
> + 		true "9 = tab"
> + 		true "10 = line feed"
> + 		false
> + 		true "12 = form feed"
> + 		true "13 = cr"
> + 		false false false false false false false false false false false false false false false false false false
> + 		true) at: integerValue + 1!
> - 	(integerValue := self asInteger) > 32 ifTrue: [ ^false ].
> - 	integerValue
> - 		caseOf: {
> - 			[ 32 "space" ] -> [ ^true ].
> - 			[ 9 "cr" ] -> [ ^true ].
> - 			[ 13 "tab"] -> [ ^true ].
> - 			[ 10 "line feed" ] -> [ ^true ] }
> - 		otherwise: [ ^integerValue = 12 "form feed" ]!
>
> Item was changed:
>  ----- Method: WriteStream>>nextPut: (in category 'accessing') -----
>  nextPut: anObject
>  	"Primitive. Insert the argument at the next position in the Stream
>  	represented by the receiver. Fail if the collection of this stream is not an
>  	Array or a String. Fail if the stream is positioned at its end, or if the
>  	position is out of bounds in the collection. Fail if the argument is not
>  	of the right type for the collection. Optional. See Object documentation
>  	whatIsAPrimitive."
>
>  	<primitive: 66>
> - 	((collection class == ByteString) and: [
> - 		anObject isCharacter and:[anObject isOctetCharacter not]]) ifTrue: [
> - 			collection := (WideString from: collection).
> - 			^self nextPut: anObject.
> - 	].
>  	position >= writeLimit
>  		ifTrue: [^ self pastEndPut: anObject]
>  		ifFalse:
>  			[position := position + 1.
>  			^collection at: position put: anObject]!


More information about the Squeak-dev mailing list