[squeak-dev] Re: Collection's #fold: vs #reduce:

Eliot Miranda eliot.miranda at gmail.com
Tue Nov 2 19:44:49 UTC 2010

On Tue, Nov 2, 2010 at 12:37 PM, Andreas Raab <andreas.raab at gmx.de> wrote:

> On 11/2/2010 12:25 PM, Eliot Miranda wrote:
>> And of course one can consider using thisContext instead of Object new
>> or {}, since thisContext has to be instantiated anyway for the closure
>> in fold:, and so results in less memory pressure.  This needs careful
>> measurement; you have the test bed set up for that; my workspace hacks
>> are showing too much variability to distinguish.
> I'm sorry but if your application is limited by the performance of
> reduce/fold you're doing it wrong. Can we discuss *clarity* of the solution
> over performance please? If we'd really need a high-performance variant,
> then *nothing* beats a trivial custom implementation in Array along the
> lines of:
> Array>>reduce: aBlock
>  result := self at: 1.
>  2 to: self size do:[:i| result := aBlock value: result value: (self at:
> 1)].
> -- "Premature optimization is the root of all evil" --

I know.  I'm joking ;)  It's still interesting to see how code generator
fallibilities make measurable differences.  I did say I thought the whoorish
speed differences were too ugly to contemplate.


> Cheers,
>  - Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20101102/562141e2/attachment.htm

More information about the Squeak-dev mailing list