Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.9.0
-
None
Description
QAnyStringView is great! I learned about it recently and really like it!
However, in some areas it still feels a bit young. At some point, it is almost always needed to extract data from it and then there are some (performance-related) issues.
We have toString(), but that will allocate a new QString. Sometimes, users don’t even want a string - they want an int, float or double - or appending to a string and then a not needed allocation is pretty expensive.
I’d like to propose adding the following:
- toInt(), toFloat(), toDouble() — like QStringView has.
- QString::operator+=(QAnyStringView) and/or QStringView::writeTo(QString&) could also be useful.
But importantly, until QAnyStringView gets these, it would be really nice to be able to handle this on the user side - but that’s not easy right now, because there are no good way to use data() without knowing the encoding of the view.
So maybe add QAnyStringView::encoding() or something similar?