[Development] RFC: Proposal for a semi-radical change in Qt APIs taking strings
Branislav Katreniak
katreniak at gmail.com
Sat Oct 17 00:08:59 CEST 2015
Thiago described Qt6 QString as { QArrayData *d; ushort* b; qsize size }.
That is pretty close to QStringView, just extra *d makes it slightly bigger.
This is how I understand this class:
QString will have (typical) case when b points into d. QString own one
reference in d in this case.
QString will have special case when b points to text section and d does not
own anything.
QString will have special case for SSO.
Can QString have special case for not owned, non persistent b pointer
(non-owning / view mode)?
Non-owning QString can be created with special static QString method. It
stays non-owning only while being passed through const &. Code that cares
about keeping QString in view mode, must stick to const QString & all the
time. Copy assignment on non-owning QString results in owning QString - it
triggers deep copy into newly created shared data.
It solves the queued connection problem that existed with QStringView
class. I suppose that queued connection internally performs QString copy.
I have no idea about performance implications for code paths that do not
care about this use case. But having just one string class would be very
convenient.
Kind regards
Brano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20151016/1354d923/attachment.html>
More information about the Development
mailing list