The role hash key is hashed twice:
- first, when calling contains method;
- second, when using operator[].
We can do better by using QHash::value.
davidedmundson |
KWin |
The role hash key is hashed twice:
We can do better by using QHash::value.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Hardly an issue... Also, if you talk about "performances and optimizations", strictly speaking QHash::value() does not allocate iterators, since it relies on the internal nodes representation.
What do you mean by "allocate iterators"? IIRC, const_iterator is just a wrapper around internal node data structure. So, underneath, that's just a pointer.
Sure, so an empty QVariant is just few mostly unallocated bytes., nothing to be worrying about.
In the end, your current patch is basically reimplementing QHash::value() for no good.