QNetworkReplyImpl: optimize QRingBuffer allocation

Use QSharedPointer<T>::create(), which co-locates the refcount with the payload
in a single memory allocation, instead of QSharedPointer<T>(new T), which causes
two allocations.

Change-Id: I84980e98c4fe9773f12533983937eafa0b0ab250
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
Marc Mutz 2014-03-11 23:17:56 +01:00 committed by The Qt Project
parent e41c6e65b5
commit a74e4b85be

View File

@ -248,7 +248,7 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingData()
if (!outgoingDataBuffer) {
// first call, create our buffer
outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer());
outgoingDataBuffer = QSharedPointer<QRingBuffer>::create();
QObject::connect(outgoingData, SIGNAL(readyRead()), q, SLOT(_q_bufferOutgoingData()));
QObject::connect(outgoingData, SIGNAL(readChannelFinished()), q, SLOT(_q_bufferOutgoingDataFinished()));
@ -367,7 +367,7 @@ void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const
// The synchronous HTTP is a corner case, we will put all upload data in one big QByteArray in the outgoingDataBuffer.
// Yes, this is not the most efficient thing to do, but on the other hand synchronous XHR needs to die anyway.
if (synchronousHttpAttribute.toBool() && outgoingData) {
outgoingDataBuffer = QSharedPointer<QRingBuffer>(new QRingBuffer());
outgoingDataBuffer = QSharedPointer<QRingBuffer>::create();
qint64 previousDataSize = 0;
do {
previousDataSize = outgoingDataBuffer->size();