I wonder if ever something along the following lines was considered?

Dictionary>>keys
        "Answer a Set containing the receiver's keys."
        
        | result |
        result := Set basicNew.
        result setTally: tally array: (array collect: [ :each |
                each isNil ifFalse: [ each key ] ]).
        ^ result

This returns a Set, so it wouldn't break any semantics. In my
benchmark this is roughly 8x faster than the current implementation,
and 2x faster than the optimized Squeak implementation.

The drawback is that it makes some heavy assumptions on the internal
structure of Dictionary, Association and Set.

Lukas

2009/12/4 Henrik Sperre Johansen <[email protected]>:
> A small addendum ;)
> On 03.12.2009 22:13, Nicolas Cellier wrote:
>> 3) identify thise sending a potential inefficient message (includes:)
>> insert keys asSet in this case (only if includes: is in a loop!)
>>
>>
> 3b. If the keys collection isn't used for anything else, change to use
> includesKey: instead.
>
> Cheers,
> Henry
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



-- 
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to