diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2021-07-10 08:17:06 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-14 20:05:41 +0200 |
commit | 41a5480cc78f9ba04be50c2481172ef86ca64079 (patch) | |
tree | dc6f24ebaeb292a6ceb2c9346d9193a5581c1fa5 /src/corelib/io/qnoncontiguousbytedevice_p.h | |
parent | 6c1bc7798bec6bc48439b297e55d14a9da0a3673 (diff) |
Hold QRingBuffer and QNonContiguousByteDevice in shared_ptr
... instead of QSharedPointer.
QSharedPointer performs twice as many atomic operations per pointer
copy as std::shared_ptr, and this is private API, we're not bound by
BC constraints, so we can port to the more efficient version.
Change-Id: I9572a8321aae381e5dbe4a51119f2c9494a8fbc7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/io/qnoncontiguousbytedevice_p.h')
-rw-r--r-- | src/corelib/io/qnoncontiguousbytedevice_p.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/corelib/io/qnoncontiguousbytedevice_p.h b/src/corelib/io/qnoncontiguousbytedevice_p.h index c570480d85..94d8e5ef9c 100644 --- a/src/corelib/io/qnoncontiguousbytedevice_p.h +++ b/src/corelib/io/qnoncontiguousbytedevice_p.h @@ -55,9 +55,10 @@ #include <QtCore/qbytearray.h> #include <QtCore/qbuffer.h> #include <QtCore/qiodevice.h> -#include <QtCore/QSharedPointer> #include "private/qringbuffer_p.h" +#include <memory> + QT_BEGIN_NAMESPACE class Q_CORE_EXPORT QNonContiguousByteDevice : public QObject @@ -85,13 +86,13 @@ class Q_CORE_EXPORT QNonContiguousByteDeviceFactory { public: static QNonContiguousByteDevice *create(QIODevice *device); - static QSharedPointer<QNonContiguousByteDevice> createShared(QIODevice *device); + static std::shared_ptr<QNonContiguousByteDevice> createShared(QIODevice *device); static QNonContiguousByteDevice *create(QByteArray *byteArray); - static QSharedPointer<QNonContiguousByteDevice> createShared(QByteArray *byteArray); + static std::shared_ptr<QNonContiguousByteDevice> createShared(QByteArray *byteArray); - static QNonContiguousByteDevice *create(QSharedPointer<QRingBuffer> ringBuffer); - static QSharedPointer<QNonContiguousByteDevice> createShared(QSharedPointer<QRingBuffer> ringBuffer); + static QNonContiguousByteDevice *create(std::shared_ptr<QRingBuffer> ringBuffer); + static std::shared_ptr<QNonContiguousByteDevice> createShared(std::shared_ptr<QRingBuffer> ringBuffer); static QIODevice *wrap(QNonContiguousByteDevice *byteDevice); }; @@ -119,7 +120,7 @@ protected: class QNonContiguousByteDeviceRingBufferImpl : public QNonContiguousByteDevice { public: - explicit QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb); + explicit QNonContiguousByteDeviceRingBufferImpl(std::shared_ptr<QRingBuffer> rb); ~QNonContiguousByteDeviceRingBufferImpl(); const char *readPointer(qint64 maximumLength, qint64 &len) override; bool advanceReadPointer(qint64 amount) override; @@ -129,8 +130,8 @@ public: qint64 pos() const override; protected: - QSharedPointer<QRingBuffer> ringBuffer; - qint64 currentPosition; + std::shared_ptr<QRingBuffer> ringBuffer; + qint64 currentPosition = 0; }; class QNonContiguousByteDeviceIoDeviceImpl : public QNonContiguousByteDevice |