Login  Register

Re: The Trunk: Collections-eem.792.mcz

Posted by Tobias Pape on May 03, 2018; 8:41am
URL: https://forum.world.st/The-Trunk-Collections-eem-792-mcz-tp5075599p5075604.html

Hi Eliot

> On 03.05.2018, at 09:56, [hidden email] 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