JUCE HashMap performance


#1

I still use the HashMap even though it's been somewhat obsoleted by std::map<> because std::map<> drives me bonkers that [] adds items to the map.

Anyway, HashMap was giving me some performance issues. My Key was a class that contains 4 Strings

Could:

ValueType  operator[] (KeyTypeParameter keyToLookFor) const
bool  contains (KeyTypeParameter keyToLookFor) const

Be changed to:

ValueType  operator[] (const KeyTypeParameter& keyToLookFor) const
bool  contains (const KeyTypeParameter& keyToLookFor) const

It stops a lot of Strings from being constructed and deconstructed for me.


#2

Sure, happy to tweak that!


#3

..actually, surely it already handles that? The KeyTypeParameter uses PARAMETER_TYPE which is supposed to choose the best form for passing that type as a parameter. Are you sure it's copying it?


#4

You are right, it's already handled in that template magic. 

Maybe I didn't have the reference on my hash function, that could have been the issue.


#5

std::unordered_map FTW !