[squeak-dev] The Trunk: Collections-nice.582.mcz

Levente Uzonyi leves at elte.hu
Sat Sep 20 15:24:09 UTC 2014


Cool. I think the spaceship operator for strings should use 
#compare:with:collated: to save a comparison in the most common case.

The performance of symbols would be close to dyadic blocks, if it were 
cheap and easy to create a block on the fly.


Levente

On Fri, 19 Sep 2014, commits at source.squeak.org wrote:

> Nicolas Cellier uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-nice.582.mcz
>
> ==================== Summary ====================
>
> Name: Collections-nice.582
> Author: nice
> Time: 19 September 2014, 10:22:13.338 pm
> UUID: 52a598f1-224e-4649-a95f-4e78547b5ed5
> Ancestors: Collections-nice.581
>
> Port TAG-SortFunctions of Travis Griggs from Cincom public store - version (11,tgriggs)
>
> Note that no collation policy were used for String.
> The spaceship operator <=> is also required in Kernel-Numbers.
>
> See also the blog http://objology.blogspot.fr/2010/11/tag-sortfunctions.html
> and http://objology.blogspot.fr/2010/11/tag-sortfunctions-redux.html
>
> Note about the cost of these sort functions:
> as shown by this mini-bench on cog, using a Symbol costs a bit more (perform:) than a block activation, and monadic block a bit more than dyadic one because activated twice more, but it seems acceptable to me with regard to the great simplification and expressiveness of code :
>
> | collec1 collec2 collec3 |
> collec1 := (1 to: 200000) collect: [:i | 1000000 atRandom-500000].
> collec2 := collec1 copy.
> collec3 := collec1 copy.
> {
> [collec1 sort: [:a :b | a abs < b abs]] timeToRun.
> [collec2 sort: [:e | e abs] ascending] timeToRun.
> [collec3 sort: #abs ascending] timeToRun.
> }
> #(345 532 912)
>


More information about the Squeak-dev mailing list