On 2017-01-31 12:50, Philippe wrote:
As far as I understand, I see a performance regression with
QStringView, for all the cases where copy-on-write can't take place
any longer.
In the following code, an extra malloc is needed. Or am I wrong?

void bar()
{
        QString s("hello");
        foo(s)
}

void foo(QStringView sv)
{
        QString str(sv);        // malloc needed
}

void foo2(const QString& s)
{
        QString str(s); // faster because of COW
}

Hi Philippe,

What will you do with str ?
If you do write operations it will detach, so the COW argument doesn't apply.
If you only do read operations then you don't even need the QString.
In fact the first malloc isn't even needed, since you could just do foo("hello") if I understand correctly.


Regards,
--
Sérgio Martins | [email protected] | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - The Qt, C++ and OpenGL Experts
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to