On 2019-05-16 20:18, Mutz, Marc wrote:
[...]
[1] Paraphrasing what Alex Stepanov teaches in his A9 courses: No C
programmer would _ever_ get the idea to use a self-rebalancing
red-black tree for something that holds a dozen elements. Because once
you understand what is required to implement one, you'd shy away from
the sheer complexity. Yet, in C++, just typing QMap makes the compiler
do all that stuff for you. Don't use a map or a hash just because you
can and the API is convenient. Use it when it makes sense, given what
data is expected to be stored. And you will invariably end up with
using vectors all over the place. According to Stepanov, developers
wishing to use a map should seek a face-to-face meeting with their
manager to explain why they need it :)
If you ever needed more convincing than an Alex Stepanov quote:
https://codereview.qt-project.org/c/qt/qtwayland/+/264069
I repeat here what I said in the commit message, only stronger:
As a library implementer, you are simply not _allowed_ the freedom to
use a convenient tool over the most efficient one. That is, to put it
mildly, a disservice to users and a disgrace to the profession of
programmers. 8KiB just to look up a pointer in a map of {string, int}?
That's 1/4th of the icache size of many processors!
And I'm not git-blaming to look up who wrote that QMap in the first
place. Qt is *full* of this stuff and you all should really understand
one thing: It's not about _your_ convenience. You are working for your
_users_. And this isn't rocket science. Almost _twenty_ years ago, Scott
Meyers wrote in Effective STL: "Prefer to use a sorted vector".
Is this code performance-critical? Probably not. But ... I mean ... 8
fscking Kilobytes. That's two pages that don't need to be paged in.
Multiply that by a 100 or so uses of QMap in a normal Qt application and
you see where this is going.
Please, think of yours truly what you want, but keep your _users_ in
mind. Users who need to strip down Qt so it fits on their devices
because ... well, because you were too lazy to pick the right data
structure.
Thanks,
Marc
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development