ulf.hermann at qt.io
Tue Jun 11 10:28:22 CEST 2019
Maybe we should move this into a more constructive direction:
I guess everybody can see that QMap and QHash are inefficient for
containers with few items. Many of us also seem to agree that just
repeating the sort/lookup on a vector all over the place is ugly and
makes the code less readable.
So, not having read the discussion about the equivalent container in
std, I'll make a naive suggestion here:
What about finding a QSortedVector that works for 90% of our internal
cases and adding that as private API (for now). The remaining 10% will
need custom solutions or keep using QHash/QMap, but replacing the 90%
will give us most of the possible efficiency gains already.
I imagine that a vector which automatically sorts itself on the first
lookup after any changes if it's larger than X items could be a drop-in
replacement for most of the places where I misuse QHash or QMap. X could
be a template parameter or found by some heuristic.
More information about the Development