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

Levente Uzonyi leves at caesar.elte.hu
Sat Mar 19 00:18:01 UTC 2016


Hi Eliot,

On Wed, 16 Mar 2016, Eliot Miranda wrote:

> Hi Levente,
>
>

snip

>>
>> But this way we save a message send, and (ab)use the fact that #== is faster than #= and is still correct (in Spur). :)
>
> Have you checked whether #== is faster in ByteArray too?  The JIT doesn't always inline SmallInteger code for special selectors since they don't always predict SmallIntegers well.  The JIT inlines #= & #~= when either the receiver or arg are literal integers, but neither are above so there will be no inlining.  There will be with #==, and that makes the ifTrue: much faster because it gets optimised to a conditional jump instruction, not a test in true or false.

It would probably be quicker, but actually I didn't want to optimize this 
rarely used method as much as it would have been possible. Were I to do 
that, I would even use primitiveIndexOfAsciiInString for longer 
ByteStrings, ByteSymbols and ByteArrays.

The only reason I tweaked these methods is that I realized that it was 
quite slow while serializing json objects. For our code, which runs on 
Squeak 4.4, this change had no effect anyway, so I just avoided these 
sends there altogether.

Levente

>
>>
>>> and/or in ByteString
>>> +       anObject isCharacter ifFalse: [ ^0 ].
>>> +       anObject asInteger < 255 ifFalse: [ ^0 ].
>>>          snip...
>>> Hem
>>> +       anObject asInteger <= 255 ifFalse: [ ^0 ].
>>> or
>>> +       anObject asInteger < 256 ifFalse: [ ^0 ].
>>> or
>>> +       anObject asInteger > 255 ifTrue: [ ^0 ].
>>
>> Right, but then you'd feel like adding it to ByteSymbol as well.
>>
>> Levente
>>
>>
>
>


More information about the Squeak-dev mailing list