[Development] Feature Freeze Exception: QStringView
Kevin Kofler
kevin.kofler at chello.at
Fri Feb 3 13:48:46 CET 2017
Marc Mutz wrote:
> QStringLiteral is not what most people use. It's too verbose.
#define U(x) QStringLiteral(x)
or some other 1-letter macro or even $ (which most compilers will let you
get away with).
> They use "&OK",
We really need a plan to deprecate implicit casts between QString and ASCII.
They are not only the source of such inefficiencies from inexperienced or
lazy programmers, but also of encoding-related bugs. If you need to convert
between 8-bit encodings and QString, you should always use a function that
specifies the correct encoding for the context (e.g. fromLocal8Bit). If your
string is constant, you should use QStringLiteral.
> and if we hopefully get SSO, QStringView-setter overhead will be greatly
> reduced.
The overhead compared to using QString will be reduced, but only part of it
(the avoided memory allocation) is really an optimization. The rest of the
"reduced" overhead is because QString will get the same overhead bloated
onto it (copying the entire string). So, sure, technically, QStringView will
have less overhead over QString, but the way you achieved that is
counterproductive. And all this is only valid for very short strings, longer
strings will still behave the same as before, except for the overhead of the
unused SSO array in both cases.
Kevin Kofler
More information about the Development
mailing list