Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9
Description
https://codereview.qt-project.org/c/qt/qtdoc/+/580545 added a really useful flow chart:
https://doc.qt.io/qt-6/string-processing.html#which-string-class-to-use
If I was a user and was faced with the overwhelming amount of string types and information about them, that is what I'd want to see in order to make the right choice.
Unfortunately, we still lack a flow chart for non-API uses, which is a significant portion of string usage.
For example, I recently read https://doc.qt.io/qt-6/qlatin1stringview.html#details. It says:
This is a bit longer to type, but it provides exactly the same benefits as the first version of the code, and is faster than converting the Latin-1 strings using QString::fromLatin1().
Thanks to the QString(QLatin1StringView) constructor, QLatin1StringView can be used everywhere a QString is expected.
Great! So I can just use it everywhere I want a Latin-1 string? Nope:
Note: If the function you're calling with a QLatin1StringView argument isn't actually overloaded to take QLatin1StringView, the implicit conversion to QString will trigger a memory allocation, which is usually what you want to avoid by using QLatin1StringView in the first place. In those cases, using QStringLiteral may be the better option.
This is too much information for someone who just wants to know which string to use. We should provide a similar flow chart to the API one to save users' time.