From fa0faf4c9ca1a0c8dda248a2502604e16eee8081 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 12 Dec 2021 14:23:58 +0100 Subject: [PATCH] QIODevice: use QVLA to hold the ring buffers, not QList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only users of more than one read- or write channel are the SCTP code and QProcess. SCTP being pretty rare, optimize for the common case of at most two QRingBuffers for reading (QProcess) and one for writing. Even with more channels, QVLA shouldn't be slower than QList - on the contrary. Need to adjust tst_toolsupport and TypeInformationVersion, as QFilePrivate::fileName has changed. Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit 63a35898f4990963fe91acd565df49111a281fa4) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qhooks.cpp | 2 +- src/corelib/io/qiodevice_p.h | 6 +++--- tests/auto/other/toolsupport/tst_toolsupport.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index 491e126b7a1..36283ec4d3f 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = { // The required sizes and offsets are tested in tests/auto/other/toolsupport. // When this fails and the change was intentional, adjust the test and // adjust this value here. - 21 + 22, }; static_assert(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h index 83c16eeddcb..e9a8af0855c 100644 --- a/src/corelib/io/qiodevice_p.h +++ b/src/corelib/io/qiodevice_p.h @@ -53,9 +53,9 @@ #include "QtCore/qbytearray.h" #include "QtCore/qiodevice.h" -#include "QtCore/qlist.h" #include "QtCore/qobjectdefs.h" #include "QtCore/qstring.h" +#include "QtCore/qvarlengtharray.h" #include "private/qringbuffer_p.h" #ifndef QT_NO_QOBJECT #include "private/qobject_p.h" @@ -134,8 +134,8 @@ public: int readBufferChunkSize = QIODEVICE_BUFFERSIZE; int writeBufferChunkSize = 0; - QList readBuffers; - QList writeBuffers; + QVarLengthArray readBuffers; + QVarLengthArray writeBuffers; QString errorString; QIODevice::OpenMode openMode = QIODevice::NotOpen; diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index 7ba4286a4db..05ed44cc165 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -142,9 +142,9 @@ void tst_toolsupport::offsets_data() #ifdef Q_PROCESSOR_X86 // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in // qglobal.h for more details. - data << 188 << 304; + data << 264 << 424; #else - data << 196 << 304; + data << 300 << 424; #endif } #endif