[Cuis-dev] Faster Collection>>#count:, Bag>>#collect: and Bag>>#count:

Luciano Notarfrancesco luchiano at gmail.com
Sun May 1 06:38:40 PDT 2022


This changeset changes Collection>>#count: to be simpler and faster (with
an Array of size 10000 I see a 35% speedup), and implements faster
Bag>>#count: and Bag>>#collect: that avoids evaluating the block on
multiple occurrences of the same element.

Both Bag>>#count: and Bag>>#collect: assume that the block is a function
(i.e., returns the same result when evaluated twice on the same element). I
think this is a fair assumption, and anyway we have the same assumption in
Bag>>#select: (which I wrote in 1998, apparently).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220501/29229b29/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5118-FasterCollectionCountAndBagCollectAndCount-LucianoEstebanNotarfrancesco-2022May01-13h21m-len.001.cs.st
Type: application/octet-stream
Size: 1268 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220501/29229b29/attachment.obj>


More information about the Cuis-dev mailing list