2015-10-17 6:23 GMT+04:00 Thiago Macieira <thiago.macie...@intel.com>:

> On Saturday 17 October 2015 03:34:51 Konstantin Ritt wrote:
> > - QString::fromRawData(u"hello world", 5) /* { d=nullptr, b=.., s=5 } */
> -
> > explicitly means "no owning, deep-copy when necessary"
>
> And when is it necessary?
>

In a given example, left() derives the original data, even when it isn't
shared, whilst leftRef() produces a non-shared QString, just like proposed
QStringView.
Then, all we need is to check `d != nullptr` in every non-const method and
simply COW, as usual. Modifying a back storage of a fromRawData string via
the high level isn't what we really should allow anyways.

Alternatively, it could be
    QString QString::left(int n) const { return QString(d ? d : new Data,
b, n); }
thus copying a part of the data when the original string isn't shared.
Though I don't like this idea too much.


Regards,
Konstantin
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to