[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sc-devel] (Identity)Dictionary : includesKey performance



The speed difference is embarrassing, about a hundredfold speedup on
my machine! I'd agree with this suggestion. It looks like it still
responds correctly to nils etc. Any reason not to?


I think it _should_ be identical, so it is a good idea to change it.

a = Bag.new;

a.add(nil);

a.contents // still empty.


There is no point to store the nil object as such in a dictionary and a the the same time separate this from "at".



Dan

2007/12/5, Sciss <contact@xxxxxxxx>:
 hello,

 should we change includesKey in Dictionary and IdentityDictionary to
 call 'at', since that is a lot faster? :

 x = IdentityDictionary.new;
 (1..1000).do({ arg key; x.put( key, \lala )})

 { a = 2000.collect({ arg key; x.includesKey( key )})}.bench;
 { b = 2000.collect({ arg key; x.at( key ).notNil })}.bench;
 a == b

 x = Dictionary.new;
 (1..1000).do({ arg key; x.put( key, \lala )})

 { a = 2000.collect({ arg key; x.includesKey( key )})}.bench;
 { b = 2000.collect({ arg key; x.at( key ).notNil })}.bench;
 a == b;



 ciao, -sciss-

 _______________________________________________
 Sc-devel mailing list
 Sc-devel@xxxxxxxxxxxxxxx
 http://www.create.ucsb.edu/mailman/listinfo/sc-devel



--
http://www.mcld.co.uk
_______________________________________________
Sc-devel mailing list
Sc-devel@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-devel


--





.