Abuse const_cast in QStringBuilder to get a little more performance
Without this const_cast, the call to QString::data() or QByteArray::data() will cause a call to detach(), which is totally unnecessary since we've just allocated data a couple of lines before. Since we know we're the owner of the only reference, we can skip the detach attempt. Change-Id: If40f66100f85cc9b405025f21c562828ead23475 Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
556c3209e2
commit
5fcee88097
@ -112,7 +112,9 @@ private:
|
|||||||
const uint len = QConcatenable< QStringBuilder<A, B> >::size(*this);
|
const uint len = QConcatenable< QStringBuilder<A, B> >::size(*this);
|
||||||
T s(len, Qt::Uninitialized);
|
T s(len, Qt::Uninitialized);
|
||||||
|
|
||||||
typename T::iterator d = s.data();
|
// we abuse const_cast / constData here because we know we've just
|
||||||
|
// allocated the data and we're the only reference count
|
||||||
|
typename T::iterator d = const_cast<typename T::iterator>(s.constData());
|
||||||
typename T::const_iterator const start = d;
|
typename T::const_iterator const start = d;
|
||||||
QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d);
|
QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user