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

Levente Uzonyi leves at caesar.elte.hu
Thu May 3 18:12:12 UTC 2018


Uh, I'm glad it wasn't me who rewrote this method. I would have used a 
primitive instead to make it even more not-even-Smalltalk-anymore.
If you don't like this kind of code, you'd better not look under the hood 
too much. Especially avoid sneaking a peek at Kernel and Collections if
you can. :)

On a serious note, libary methods, like that method, ought to be fast, 
because you can't know in what situation they will be used. Saying that 
it's not even used is therefore not a valid reason.

Levente

On Thu, 3 May 2018, Chris Muller wrote:

> +1.  Not only that, why the call to #basicSize and #basicAt:.  Really?
>
> It's like...  not even Smalltalk anymore...   :(
>
> On Thu, May 3, 2018 at 3:41 AM, Tobias Pape <Das.Linux at gmx.de> wrote:
>> Hi Eliot
>>
>>> On 03.05.2018, at 09:56, 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.792.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Collections-eem.792
>>> Author: eem
>>> Time: 3 May 2018, 12:55:52.175146 am
>>> UUID: 7d8995ed-835e-44b0-bf4c-0b0780f5c96f
>>> Ancestors: Collections-pre.791
>>>
>>> Four times faster implementation of isAsciiString.
>>>
>>> =============== Diff against Collections-pre.791 ===============
>>>
>>> Item was changed:
>>>  ----- Method: String>>isAsciiString (in category 'testing') -----
>>>  isAsciiString
>>> +     "Answer if the receiver contains only ascii characters.
>>> +      Inline ^self allSatisfy: [ :each | each asciiValue <= 127 ] for speed."
>>> +     1 to: self basicSize do: [:i| (self basicAt: i) > 127 ifTrue: [^false]].
>>> +     ^true!
>>> -
>>> -     ^self allSatisfy: [ :each | each asciiValue <= 127 ]!
>>>
>>>
>>
>> Although I am in awe of the performance improvement, I am curious wether it really pays of to inline #allSatify: here, in terms of performance vs. readability.
>>
>> I presume that, given the current use of #isAsciiString, we can stay with the more compact, readable version that does not need the 'caveat lector'-comment at the beginning of the method.
>>
>>
>> Best regards
>>         -Tobias
>>
>>


More information about the Squeak-dev mailing list