[Development] Feature Freeze Exception: QStringView

Milian Wolff milian.wolff at kdab.com
Fri Feb 3 11:36:44 CET 2017


On Freitag, 3. Februar 2017 10:59:21 CET Kevin Kofler wrote:
> Marc Mutz wrote:
> > The question of whether to replace QString sink arguments with QStringView
> > ones is an open one. It does not affect the usefulness of QStringView as a
> > way to pass UTF-16 data from a wide variety of sources through a single
> > function.
> > 
> > I'd invite you to look at the QColor port to QStringView
> > (https://codereview.qt-project.org/184038) to see for yourself, but past
> > experience has left me with the feeling that it'd be pointless...
> 
> I had actually already looked at that patch, but looking at it again, it is
> true that it at least avoids the deep-copy issue because setColorFromString
> is a template that takes any string type. If, on the other hand, it would
> take a QString, or it would take a QStringView, but then have to store the
> string persistently (which means it needs to be converted to QString or
> something equivalent to remain valid), we would get an extra deep copy. I am
> not sure how many contexts can be safely changed as in your patch. But even
> the way it is, there may still be a loss of efficiency in the common case
> where what is passed is a QString, depending on what the compiler inlines,
> whether the wrapper with the QString argument is compiled in or not, etc.

If that is the case, then the API can have an overload taking an existing 
QString and store it directly. This would be a simply optimization.

-- 
Milian Wolff | milian.wolff at kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5903 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170203/b18c8efd/attachment.bin>


More information about the Development mailing list