A significant performance difference

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 1 02:22:50 PDT 2014


ketmar:

>> But I think the "j = x.byKey.front;  p = x.byValue.front;" 
>> code looks sufficiently idiomatic, and its performance is 
>> terrible.
>
> that's why i suggest to extend AA API, adding x.firstKey and
> x.firstValue functions. i'll try to make the patch soon.

In theory the best solution is to improve the performance of the 
"byKey.front" and "byValue.front" idioms.

If that's not possible and you need to add the 
firstKey/firstValue functions, then it's a good idea to make the 
D front-end rewrite "byKey.front" with a call to "firstKey" and a 
"byValue.front" with a call to firstValue.


> ah, and x.getAndRemove() too, it's handy sometimes. but this 
> will need new druntime hook, i think. ;-)

x.pop() sounds nicer :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list