I couldn't help but noticing that most methods in the math function category of Collection follow the form
foo ^ self collect: [:each | each foo]
yet squared ^ self collect: [:each | each * each]
Ah,is this an issue? Well each * each is the math for squared, but are there special cases?
Yes Fraction has a special case of squared. So if I change Collection>>squared to
^self collect: [:each | each squared]
Then squaring a collection of fractions now takes 62% of the original time, because Fraction>>squared is much faster than Fraction>>* (140ms)
But on the other hand array of numbers foo squared runs 20% slower (36ms) because we have another method call to make to get to the point of each * each.
So thoughts are welcome. I didn't really see any collections being squared in the image so I'm not sure of the impact.
squeak-dev@lists.squeakfoundation.org