#select:thenDo: in Squeak
I'm surprised to see that Collection>>#select:thenDo: in Squeak is simply:
I would have expected more optimized:^ (self select: selectBlock) do: doBlock
While this would change the order of execution slightly, it would seem to be faster, given that I won't end up creating the intermediate collection. Similar optimizations seem available for #reject:thenDo:. And a cursory glance at various #select: implementations probably wouldn't pessimize this optimization.^ self do: [:each | (selectBlock value: each) ifTrue: [doBlock value: each]]
Comments
I took a look around at Dolphin, VisualWorks, Stongtalk, SmalltalkMT and Smalltalk/X for what they do. Pretty much none of them have a similar method except for Smalltalk/X which implements it exactly like you have suggested...
sorry about previous post... something went wrong with the formatting...
Anyway as I was saying Smalltalk/X does implement it exactly as you have suggested and since it implements it in terms of #do: then Disctionary will take advantage of this optimisation.
This may break certain clients...??