summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
...
* QMap: add missing qHash() overloadMarc Mutz2024-02-092-0/+36
| | | | | | | | | | | | | | | | | | | Found in API review, but not deemed important enough to still get into 6.7. Not implementing it for QMultiMap, because there we need to mod out order of equivalent elements. The GHS compiler acted up and tried to compile the noexcept specification, hitting non-existing qHash(QVariant) for QVariantMap and producing a hard error instead of SFINAE'ing out. As a work-around, establish an artificial SFINAE-friendly context, but only for that compiler. [ChangeLog][QtCore][QMap/QHash] Added qHash() overload for QMap. Change-Id: Ia7dbf488e8e5490962118e40581b7c4cc8ed95e5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QVersionNumber: apply LWG 3346 work-aroundMarc Mutz2024-02-081-0/+2
| | | | | | | | | | | | QtWebEngine builds using GCC 10.2 have hit the GCC < 10.4 problem with containers that define both element_type and value_type, so lift the work-around from QList to QVersionNumber, too. Amends 2188ca2c5df6f21a953c002edbe5b2d2cc2c2d2c. Fixes: QTBUG-122037 Change-Id: Idb59b5325ab6308cfd7d1a5559e45a01a5802099 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QSpan: apply LWG 3346 work-aroundMarc Mutz2024-02-081-5/+8
| | | | | | | | | | | | | We have not hit the GCC < 10.4 problem with containers that define both element_type and value_type, yet, but we have with QVersionNumber, so proactively apply it to QSpan, too. While we're at it, copy the QList code to mark QSpan, too, as contiguous. Pick-to: 6.7 6.6 Change-Id: I883fd0b5f75db175a730262035ebbf0cb19de529 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QList: give the LWG 3346 #ifdef'ery a symbolic nameMarc Mutz2024-02-081-4/+2
| | | | | | | | | | | We'll need this in more places, so centralize its definition in qcompilerdetection.h. Amends 595b4e1a9b436a8190964dc41f79621400f5a6be. Pick-to: 6.7 6.6 6.5 Change-Id: I87f84cb9ff3ad339c000604423295180176f5799 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qHash: provide the long double overload on Darwin systemsThiago Macieira2024-02-032-4/+0
| | | | | | | | | | | | Commit c0791ac76ec7cfdc3945efa67a6f72ee3623413c didn't explain why it was #ifdef'ed out. It's just an alias for double. Maybe compilers at the time used to complain if you used it, but I can't make Apple's clang produce a warning now. Pick-to: 6.7 Change-Id: I664b9f014ffc48cbb49bfffd17b02293403e9571 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QBitArray: defend resize() and fromBits() against negative sizesMarc Mutz2024-02-031-2/+4
| | | | | | | | | | | Use the same technique the constructor already uses: Q_ASSERT followed by selecting the no-op branch in case assertions are compiled out. Pick-to: 6.7 Change-Id: I24cbcfd686f67e060134baecfb21044948b6eb98 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QBitArray: use QDataStream::SizeLimitExeeded where applicableMarc Mutz2024-02-031-2/+2
| | | | | | | | | | | [ChangeLog][QtCore][QBitArray] Uses new QDataStream::Status::SizeLimitExceeded now, where applicable (was: WriteFailed, ReadCorruptData). Pick-to: 6.7 Change-Id: If5a8db9c6b2f104b40266784d88cf7cad0b0ce73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Change license of .qdoc filesLucie Gérard2024-02-024-4/+4
| | | | | | | | | | | | According to QUIP-18 [1], all .qdoc files should be LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I7c4d8a1957db6f6d7ad18cbc1928499724e9305f Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QBitArray: simplify resize()Marc Mutz2024-02-021-5/+1
| | | | | | | | | | Use the new (in Qt 6.4) QByteArray::resize(n, ch) to avoid the manual memset() unpleasentness. Pick-to: 6.7 Change-Id: I786988125f52b1bc1f733c30ab2b95eda569481d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QBitArray: simplify (size, value) ctorMarc Mutz2024-02-021-3/+1
| | | | | | | | | | Don't do the memset() manually just to save re-writing the single leading byte. Pass the initial values to the QByteArray constructor directly. Pick-to: 6.7 Change-Id: I67daf446bebb8c8c6b05d235746ee43604f42445 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBitArray: don't create invalid Qt 5 streamsMarc Mutz2024-02-021-0/+4
| | | | | | | | | | | | | | | | | Qt 5 streams cannot handle QBitArrays with more than INT_MAX bits, even on 64-bit platforms, because of interface constraints (size_type int). Qt 6 can, so make sure to refuse serialization of oversized QBitArrays to Qt-5-compatible streams. [ChangeLog][QtCore][QBitArray] Now refuses to stream a QBitArray with size() > INT_MAX to a Qt-5-compatible QDataStream. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I263e27bd366757c8e0360dfd337948c44d00647a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QBitArray: DRY operator<<(QDataStream&)Marc Mutz2024-02-011-10/+6
| | | | | | | | | | | | | | | | | Drag the common parts out of the if-else. This also means that qsizetype size() is no longer truncated in the assignment to quint32 len, but that doesn't fix the problem that we create invalid Qt 5 streams when the QBitArray has more than INT_MAX bits in it. That is for a follow-up patch (which is why the {} stay for now). As a drive-by, replace verbose constData() with data() (the QByteArray is already const). Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Iabf816e16f823bb3959469a635a21339242f36fc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QBitArray: avoid overflow in storage-to-size calculationsMarc Mutz2024-02-012-23/+22
| | | | | | | | | | | | | | | | | | Unlike other containers, a QBitArray's size() is not limited by storage, but, esp. on 32-bit platforms, its size_type: A INT_MAX size() QBitArray only requires 256MiB of storage. So we can't rely on "won't happen in practice" here and need to avoid the potential UB (signed overflow) in the (d.size() * 8 - *d.data()) storage-to-logical-size calculation by using unsigned arithmetic. Use the opportunity to Extract Method adjust_head_and_tail(), centralizing the bit fiddling. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I485eafdf3ce2087a81c683672ff98a43f97c9968 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QHash: improve perf when detaching with potential growthMårten Nordheim2024-01-311-1/+1
| | | | | | | | | By not assuming we will have resized. reserve(size() + 1) will have suffered a bit from this, but that is probably not very common. Change-Id: I8750d430f532a72729ed06e67c0f315707a916d6 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* QVersionNumber: make iterableMarc Mutz2024-01-312-0/+122
| | | | | | | | | | | Since QVersionNumber doesn't have an existing way to modify individual segments, provide only const_iterator. [ChangeLog][QtCore][QVersionNumber] Added (const) iterators over segments (begin()/end(), incl. c- and r- variants). Change-Id: Ia9af70c2a9c59f630123894ad2c9f38031ef5b8f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QtPrivate::ArrowProxyMarc Mutz2024-01-312-18/+10
| | | | | | | | | | | | | | | | ... use it in QKeyValueIterator. This is somewhat simpler than the old QKeyValueIterator::pointer. I don't think the pointer::operator*() could have ever worked, because it returns value_type&, but is const. That leaves the defaulted copy and move SMFs as a difference (ArrowProxy is using aggregate initialization, so doesn't need any), and the fact that operator->() is const. Change-Id: I80b9c5f696de6ae30f3939166b205b9213eac57e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBitArray: apply Rule Of ZeroMarc Mutz2024-01-312-0/+7
| | | | | | | | | | | Can't do it now, because this non-polymorphic class is exported wholesale, so removing the SMFs would be BiC. But pre-program for Qt 7, so we don't forget again. Change-Id: I36420dbaeda53391d304cf6832167f6157c22e35 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QBitArray: fix potential truncation in QDataStream op>>()Marc Mutz2024-01-311-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | In Qt 5, a QBitArray could not contain more than INT_MAX bits, because the then-size_type, int, cannot represent more, even if the underlying storage could hold 8x as much, and the serialisation format, using unsigned int, could represent 2x. Therefore, reject old formats with sizes that exceed INT_MAX elements as corrupt. Likewise, the Qt 6 serialisation format unconditionally uses 64-bit sizes, but 32-bit platforms still cannot represent more than numeric_limits<qsizetype>::max() (= INT_MAX) bits in memory. This is a valid stream for 64-bit platforms, though, so ideally, this should be using SizeLimitsExeeded, which, however, is only available from Qt 6.7. So, for now, and until we have SizeLimitsExeeded, mark the stream as corrupt here, too. [ChangeLog][QtCore][QBitArray] Fixed undetected overflows in the deserialisation (opertor>>()) from QDataStream. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ib24cf9218c06a3a05185723c77d4313611c2dd40 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bootstrap: remove QBitArrayMarc Mutz2024-01-312-0/+6
| | | | | | | | | | It appears to be used only in qlalr, which is, however, not bootstrapped. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: Idc16d957bf687238c7b0ee603d8b092e2048ef18 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBitArray: avoid overflow in size-to-storage calculationsMarc Mutz2024-01-301-4/+15
| | | | | | | | | | | | | | | | | | | | | | | Unlike other containers, a QBitArray's size() is not limited by storage, but, esp. on 32-bit platforms, its size_type: A INT_MAX size() QBitArray only requires 256MiB of storage. So we can't rely on "won't happen in practice" here and need to avoid the potential UB (signed overflow) in the (size + 7) / 8 logical-to-storage-size calculation by using unsigned arithmetic. Use the opportunity to Extract Methods storage_size() and allocation_size(), which differ by one (d[[0] contains the size() mod 8), making it clear what's what. [ChangeLog][QtCore][QBitArray] Fixed a bug with QBitArrays whose size() came within 7 of the size_type's maximum. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I5d94bae9c9c210ba1e36f8cf03609125c81bd15d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QBitArray: correct inline keywordMarc Mutz2024-01-291-2/+2
| | | | | | | | | | | | The mutable operator[] method was marked as inline only at the definition, not the declaration. This is known to cause compilation failures on MinGW when the function is used in other inline implementation (cf. e.g. QTBUG-56459). It's not, atm, but fix the issue proactively. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: If805122d9f8dbd72641173509c4b860c20fc1cdc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QSpan: make adl_begin() etc SFINAE-friendlyMarc Mutz2024-01-261-3/+14
| | | | | | | | | | | | | | The definition of iterator_t, and, therefore, of is_compatible_range depends on this, otherwise say, 0, is being treated as a valid range and hits a hard error in adl_begin() when trying to call begin(int&). TIL: decltype(auto) does _not_ SFINAE. Fix by calculating the return type manually, re-enabing SFINAE. Pick-to: 6.7 6.6 Change-Id: Icacd70554f4050ecaeb396c9ae60bc4f21a220c9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* [docs] QVersionNumber: fix a typoMarc Mutz2024-01-241-1/+1
| | | | | | | | | | Use "Constructs" instead of "Construct" in the initializer_list ctor docs, because it's what all other ctor docs also use. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Ie84d208b81a062851d95fb336553e8e7c57d4b73 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize QSet::uniteAllan Sandfeld Jensen2024-01-201-4/+7
| | | | | | | Done similar to intersect. This also improves one test, as we get one less detach, and makes it consistent with other results. Change-Id: I4d08bf43e750c758b363f8e4fe1fe312a7a0cde4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Dissociate QTypeRevision from QVersionNumberMarc Mutz2024-01-104-348/+400
| | | | | | | | | | | | | | | | They have nothing to do with each other, so give QTypeRevision its own header and implementation file instead of piggy-backing on QVersionNumber's. Picking back to current LTS to incur the merge conflict only once, not per (expected) follow-up change. Amends ed080c64ae21d22115d16780a5903d7cc4fd1546. Pick-to: 6.7 6.6 6.5 Change-Id: I2fa5d0e68f95864126bc95e3d8154134eee85553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* [docs] Remove references to C++11 feature availabilityMarc Mutz2024-01-095-21/+4
| | | | | | | | | | | | | QVersionNumber, e.g., was added for Qt 5.6, the last Qt version that didn't require C++11. So it made sense that the original documentation stated that certain functions were only available in C++11 mode. But already Qt 5.7 required C++11, so these historical anecdotes are no longer pertient to today's Qt users, so remove them from the docs. Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I5c732d3b9b33e1fb6947eff4fac546476c8379f2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix documentation issues for Qt CoreTopi Reinio2023-12-192-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix template arguments in \fn signatures for Qt::compareThreeWay() functions. * Fix template arguments in \fn signatures for QDebug::operator<<() functions. * Fix \sa links to specific overloads of QSpan functions. * Fix \sa links to specific overloads of QFileInfo::fileTime(). * Remove references to 'Custom Type Example' (example has been removed). * Fix linking to 'JSON Save Game' example. * Fix references to 'Queued Custom Type' example. * Fix linking to QCryptographicHash::Algorithm. * Fix linking to Qt Qml module. * Fix undocumented parameters in qHypot(). Pick-to: 6.7 Change-Id: If9eb9978a14e147f003672a682972b319454c311 Reviewed-by: Luca Di Sera <luca.disera@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Doc: Remove references to Qt 4 in Qt 5.0 in Qt Core documentationKai Köhne2023-12-181-2/+1
| | | | | | | Pick-to: 6.6 6.7 Change-Id: Ide0c1ed441c923753f1e81141460719161662c15 Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io> Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
* QBitArray: add mutation operators taking rvalue QBitArraysThiago Macieira2023-12-142-24/+88
| | | | | | | | | | | | | | | | | Because we may be able to use the other side's storage and apply the operation in-place. We reuse the storage of the one that can be detached: even if we have to grow the buffer, QBitArrays are usually small so there's a good chance it's just to the extra space QArrayData usually overallocates or a simple, non-moving realloc(). Disassembly with GCC 13 and Clang 17 show the vectorisers did kick in for all four functions (inverted_inplace included). I think a hand-rolled version could squeeze a few more cycles, especially in the tail section, but I don't consider its maintenance cost to be worth it. Pick-to: 6.7 Change-Id: I85b3fc2dd45c4693be13fffd1795bfb1b296caa6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add QT_NO_QPAIRMarc Mutz2023-12-142-0/+6
| | | | | | | | | ...and mark QtCore as free of QPair. Task-number: QTBUG-115841 Pick-to: 6.7 Change-Id: Ic6009d3cabbf72b3b3fe966e47d48a80a328b499 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QVariantPair: cut the QPair middle-manMarc Mutz2023-12-131-1/+1
| | | | | | | | | Use std::pair directly. Task-number: QTBUG-115841 Pick-to: 6.7 Change-Id: I4ca63c7b7f46f2b66f6f4f4ef4eba54537d5dc7a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QArrayData/Pointer: s/QPair/std::pair/Marc Mutz2023-12-133-10/+10
| | | | | | | | | | Also port from qMakePair to just braced initialization and CTAD. Task-number: QTBUG-115841 Pick-to: 6.7 Change-Id: Ifd7220ae88b101351e91d1488ce18715eb4880e5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: Fix fn commands for QSpanLuca Di Sera2023-12-131-32/+32
| | | | | | | | | | | | | | | Added a return type where it was missing as Clang would otherwise fail to parse the command. Qualified certain non-type template parameter that were based on a using declaration inside the QSpan class. An `\fn` command is parsed as a fake out-of-line definition. In that context, the unqualified name will not be able to be solved by Clang, resulting in an inability to match the element. Pick-to: 6.7 Change-Id: I929ab5e8df4f7a6ef5d913266b584cd0393074e3 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QBitArray: add rvalue binary bitwise operatorsThiago Macieira2023-12-122-3/+32
| | | | | | | | | Now that the assignment-bitwise operators can reuse storage, we can make these operators also be capable of reusing storage. Pick-to: 6.7 Change-Id: I85b3fc2dd45c4693be13fffd1795b893de65a5b8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QBitArray: un-export QBitRef for Qt 7Thiago Macieira2023-12-131-1/+1
| | | | | Change-Id: I85b3fc2dd45c4693be13fffd1795b66f54297c63 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QBitArray: improve memory allocation in the binary bitwise operatorsThiago Macieira2023-12-122-12/+71
| | | | | | | | | | | | Instead of creating a temporary copy of one of the two sides (which will share QByteArray), create one with the correct target size such that it is already detached. Drive-by move them to hidden friends. Pick-to: 6.7 Change-Id: I85b3fc2dd45c4693be13fffd1795b74eeaf3be71 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QMap/QHash: s/QPair/std::pair/Marc Mutz2023-12-135-24/+24
| | | | | | | | | Also port from qMakePair to just braced initialization using CTAD. Task-number: QTBUG-115841 Pick-to: 6.7 Change-Id: Ib0ad55d7110521e34004dc9050022f9c0046722e Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* qpair.h: remove duplicate QPair alias definitionMarc Mutz2023-12-131-3/+1
| | | | | | | | The original is in qcontainerfwd.h these days, so just include that. Pick-to: 6.7 Change-Id: I1d0adaf528f158c48caf47d65b20d09eff06f57d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qarraydata.h: don't rely on transitive include of qflags.hMarc Mutz2023-12-131-0/+1
| | | | | | | | | The QFlags header came in via qpair.h and broke when we tried to remove qglobal.h from qpair.h. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I335b84cc1d73303f8f2497427a21fba255ee11f9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt QMutableHashIterator to change in QMultiHashCarl Schwan2023-12-131-3/+2
| | | | | | | | | QMultiHash doesn't inherit from QHash since Qt 6.0 so we can't use QMutableHashIterator anymore with QMultiHash. Pick-to: 6.6 6.5 6.7 Change-Id: I9e755899e0a1e331f452a618b6d8a127715c54d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayData: move AlignedQArrayData to the public headerThiago Macieira2023-12-112-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | This allows us to use it in QTypedArrayData<T>::AlignmentDummy, which is used in __builtin_assume_aligned() as a hint to the compiler. This increases the value we were passing as the compiler hint from 4 to 8 on 32-bit platforms and from 8 to 16 on 64-bit platforms. We actually do align to a bit higher than even that, but that's not an ABI guarantee we're making. However, it looks like GCC on 32-bit platforms is buggy, so we work around it. Commit r240248 ("Make max_align_t respect _Float128.", 63012d9a57edc950c5f30242d1e19318b5708060 in Git) increased std::max_align_t to 16 bytes on all platforms, saying "Such an increase is of course an ABI change" and "I think glibc malloc alignment should also increase to 16-byte 32-bit x86", but such a change to glibc was never implemented. Moreover, there are systems that don't use glibc, such as when using GCC on other OSes. This is not a change in Qt behavior anywhere. i386 does not (usually) do alignment checks, so most code wouldn't notice this at all. Pick-to: 6.7 Change-Id: I79e700614d034281bf55fffd178fa0aee2344307 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QArrayData: add allocate1 and allocate2 for 1- and 2-byte typesThiago Macieira2023-12-112-23/+73
| | | | | | | | | | | | | | | | This makes the two most-often used QTypedArrayData::allocate() -- the ones for char (for QByteArray) and char16_t (for QString) -- go to specialized versions, which have much simpler code. After all, multiplications by 1 are quite trivial. I didn't check whether an LTO compiler was const-propagating the sizes in inlined calls from qstring.cpp and qbytearray.cpp. But not everyone uses LTO, so this benefits everyone, in a very hot path, for minimal cost. Pick-to: 6.7 Change-Id: Ifa1111900d6945ea8e05fffd177dd1ce659b3fd5 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add tests for CompactStorageMarc Mutz2023-12-081-0/+47
| | | | | | | | | | They're too trivial for their own QTestLib-based approach, but we don't want them in the header, either, reducing the compile times for all users, so put them into an otherwise empty .cpp file. Change-Id: Iae7fc4d4a29a0648b91752040854288e02da7045 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QAtomicScopedValueRollback public APIRym Bouabid2023-12-082-16/+4
| | | | | | | | | | | Move the private header to public. Make documentation a part of public interface. [ChangeLog][QtCore][QAtomicScopedValueRollback] New class. Task-number: QTBUG-115107 Change-Id: I6c9f5448e74a5b62f4d97ee079944f4b1b731121 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QBitArray: replace the member operator~ with a hidden friendThiago Macieira2023-12-072-6/+20
| | | | | | | | | | | | | | Which takes the array to be inverted by value, so we get free move semantics and allowing us to perform the negation in-place. [ChangeLog][Potentially Source-Incompatible Changes] The bitwise AND, OR, XOR, and NOT operator functions on QBitArray are now hidden friends. This may cause source-incompatibility in unusual coding styles (like 'array.operator~()') or with classes that have a casting 'operator QBitArray()'. Change-Id: I85b3fc2dd45c4693be13fffd1795ba1fbaf23769 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QBitArray: refactor operator~() to write to an uninitialized bufferThiago Macieira2023-12-072-11/+22
| | | | | | | No functionality change otherwise. Change-Id: I85b3fc2dd45c4693be13fffd179627b2747c132b Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QSpan: add some C++20 reminder code commentsMarc Mutz2023-12-071-1/+3
| | | | | Change-Id: I1cd698bde290cbd37d13103cd6832a739d9c548b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live QSpan as public API!Marc Mutz2023-12-074-401/+1067
| | | | | | | | | | | Provide qspan_p.h as backward-compatibility header. [ChangeLog][QtCore][QSpan] New Qt equivalent of std::span. Fixes: QTBUG-115022 Change-Id: I1cc27dc0aa1f7406f0a41d7a75f176cd7f858feb Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSpan: fix an MSVC warning-turned-error:Marc Mutz2023-12-071-1/+1
| | | | | | | | | | | | qspan_p.h(35): error C2220: the following warning is treated as an error qspan_p.h(35): warning C4245: 'initializing': conversion from 'int' to 'const size_t', signed/unsigned mismatch Add an explicit (functional-style) cast to silence it. Pick-to: 6.6 Change-Id: Id29fda3def1c60415b3e0fe72eaf82c8bc57d363 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add documentation for the private API QAtomicScopedValueRollbackRym Bouabid2023-12-071-0/+124
| | | | | | | | Task-number: QTBUG-115107 Pick-to: 6.6 6.5 Change-Id: Icdb09d803f1d789b91ae5c1806470d71adb59067 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>