summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qlist
Commit message (Collapse)AuthorAgeFilesLines
* QList: add uninitialized resizesGiuseppe D'Angelo2024-02-161-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating a QList of a given size, or resizing it to a given size, will always value-initialize its elements. This commit adds support for uninitialized construction and resizes. The intended use case is using a QList as storage-to-be-overwritten: QList<int> list(size, Qt::Uninitialized); fillWithData(list.data(), list.size); How do we define "uninitialized": 1) if T is constructible using Qt::Uninitialized, use that; 2) otherwise, default-construct T. In detail: 1) covers (Qt-ish) datatypes that have a default constructor that initializes them, but also a dedicated constructor that doesn't initialize (e.g. QPoint, QQuaternion, ...). 2) covers everything else. Default initialization of scalars and trivially constructible datatypes will leave them uninitialized. A type which isn't trivially constructible will still get its default constructor called (and possibly actually gets initialized); we can't really do better than that, as we still have to construct objects and start their lifetimes. [ChangeLog][QtCore][QList] Added support for uninitialized construction and resizing. Change-Id: I32c285c7dddbf7e01475943f24e14e824bb13090 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: give the LWG 3346 #ifdef'ery a symbolic nameMarc Mutz2024-02-081-1/+1
| | | | | | | | | | | 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>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Make QAtomicScopedValueRollback public APIRym Bouabid2023-12-081-1/+1
| | | | | | | | | | | 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>
* QArrayDataPointer: remove Q_CHECK_PTR in assign(it, it) againDennis Oberst2023-09-071-0/+20
| | | | | | | | | | | | | | | | | | | | | | | This commit reverts 2d77051f9dfd11ae292ad4bac2f28c5f7a0e7f83. When requesting an allocation of size 0, we will actually get a nullptr. qarraydata.cpp: ~~~ if (capacity == 0) { *dptr = nullptr; return nullptr; } This will let the Q_CHECK_PTR trigger falsely. Such an occurrence was initially detected during the cmake_automoc_parser build-step. Found-by: Marc Mutz <marc.mutz@qt.io> Task-number: QTBUG-106196 Pick-to: 6.6 Change-Id: Icb68c5dd518c9623119a61d5c4fdcff43dc4ac5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QArrayData: make calculateBlockSize() account for the extra null elementThiago Macieira2023-09-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of adding it after the block size was calculated. This makes no difference for non-growing (exact) blocks. For growing blocks, this means we take that extra element into account before rounding to the next power of two, instead of after. That results in a change of the thresholds of when a block grows and also what capacity it will contain. For example, for a QString growing to 22-25 elements: Request | Previously | Now | elements | bytes | malloc()ed | capacity() | malloc()ed | capacity() | 22 | 44 | 66 | 24 | 64 | 23 | 23 | 46 | 66 | 24 | 64 | 23 | 24 | 48 | 66 | 24 | 128 | 55 | 25 | 50 | 130 | 56 | 128 | 55 | To avoid wasting elementSize - 2 bytes in this footer, we only include this footer if elementSize <= 2. Thus, for a QList<int> growing to 11-13 elements: Request | Previously | Now | elements | bytes | malloc()ed | capacity() | malloc()ed | capacity() | 11 | 44 | 66 | 12 | 64 | 12 | 12 | 48 | 66 | 12 | 128 | 28 | 13 | 52 | 130 | 28 | 128 | 28 | In both cases, we now only allocate powers of two while growing, which may be beneficial to some allocators. Pick-to: 6.6 Change-Id: Ifa1111900d6945ea8e05fffd177dcb96e251d0a1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tests/auto/: port Q_FOREACH to ranged-for, local const containersAhmad Samir2023-08-191-11/+6
| | | | | | | | | | | | | | | | | | | | These are local containers that are either: - Already const and didn't need Q_FOREACH to begin with - Can be simply made const, just by adding const keyword In one case the unittest checked that the container's size is 1, so use list.first() instead of a for-loop. In files where Q_FOREACH isn't used any more, remove "#undef QT_NO_FOREACH". Also remove those files from NO_PCH_SOURCES. Drive-by changes: - Remove parenthesis from one-line for-loops - Make the for-loop variable a const& where a copy isn't needed Task-number: QTBUG-115839 Change-Id: Ide34122b9cda798b80c4ca9d2d5af76024bc7a92 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-051-0/+6
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: re-use the prepend buffer, if any, on assign()Marc Mutz2023-05-171-10/+95
| | | | | | | Task-number: QTBUG-106196 Change-Id: I62d8610529cab528ae1b114d29707133b4fc28dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QList: add STL-style assign()Dennis Oberst2023-05-161-0/+64
| | | | | | | | | | | | | | | Implemented assign() methods for QList to align with the criteria of std::vector, addressing the previously missing functionality. Reference: https://en.cppreference.com/w/cpp/container/vector/assign [ChangeLog][QtCore][QList] Added assign(). Fixes: QTBUG-106196 Change-Id: I5df8689c020dafde68d2cd7d09c769744fa8f137 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-171-2/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-281-1/+1
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Long live QAtomicScopedValueRollback (private API)!Marc Mutz2022-05-312-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | QScopedValueRollback has a few users that apply it on QAtomicInt, which happens to work as QAtomicInt is copy-constructible and its ctors are implicit. But that's of course nonsense. We don't need to store the oldValue in an atomic, nor do we need to pass the new value into the ctor as an atomic. So, add a QAtomicScopedValueRollback which works on std::atomic as well as the Qt atomics, but distinguishes between the reference (which is atomic) and the value (which isn't), and use it in one of the users, tst_QList. Keep it private until we know whether there's an actual need for this. The test is a copy of tst_qscopedvaluefallback, so the occasional oddity (like atomic op*=) should be ignored. Task-number: QTBUG-103835 Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix build with C++20 on macOSAllan Sandfeld Jensen2022-02-111-1/+1
| | | | | | | | | | The macOS standard library doesn't have std::contiguous_iterator yet, and it doesn't seem like libc++ has it either. Checking __cpp_lib_concepts for the C++20 official version appears to work. Pick-to: 6.3 6.2 Change-Id: I8c31cd64de24c03b3a3f37cb393bb2f9b55a834d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QList: avoid a iterator->pointer conversion in the testGiuseppe D'Angelo2021-10-141-1/+1
| | | | | | | | Being a test, I'm going to abuse operator-> on end() to check that we get what we want (a pointer past the end). Change-Id: I7ab8d017b0fe320018820eff336d496328ade481 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QList::iterator: use templates for advancing operatorsThiago Macieira2021-10-121-0/+134
| | | | | | | | | | | | | | | | | | | | | | | | | Because of the addition of the operator T*(), the expression "it + N" where N was not exactly qsizetype but any other integer type was a compilation failure because of ambiguous overload resolution. With GCC it's apparently a warning: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: note: candidate 1: ‘QList<T>::iterator QList<T>::iterator::operator+(qsizetype) const [with T = char; qsizetype = long long int]’ note: candidate 2: ‘operator+(char*, ptrdiff_t {aka long int})’ (built-in) With Clang, it's an error: error: use of overloaded operator '+' is ambiguous (with operand types 'QList<int>::const_iterator' and 'ptrdiff_t' (aka 'long')) note: candidate function inline const_iterator operator+(qsizetype j) const { return const_iterator(i+j); } note: built-in candidate operator+(const int *, long) Pick-to: 6.2 Fixes: QTBUG-96128 Change-Id: Ie72b0dd0fbe84d2caae0fffd16a06f23dd56b060 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove checks for features available in C++17Ievgenii Meshcheriakov2021-10-021-4/+0
| | | | | | | | | | This patch removes most of the checks that are made using C++20 __cpp_* macros for features available in C++17 and earlier. Library feature check macros (__cpp_lib_*) are unaffected. Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: extend testsIvan Solovev2021-07-201-13/+428
| | | | | | | | | | | | | | This patch mostly introduces some test improvements to check the calls of different methods on an empty default-constructed container. Apart from that some other tests are added to extend test coverage. Task-number: QTBUG-91736 Pick-to: 6.2 6.1 Change-Id: If2bc96158462292bbdf8504942141af94568c729 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add more tests for QList/QString/QBAAndrei Golubev2021-04-271-27/+357
| | | | | | | | | | | | | | | | The major part is stability tests for QList operations, Also added std::shared_ptr to the Custom type. shared_ptr accesses the memory which does not directly belong to QList, so using it inside a passed-to-qlist type is beneficial (e.g. ASan could catch extra issues) Basic prepend-aware cases added to QString/QBA tests Task-number: QTBUG-93019 Change-Id: I50e742bdf10ea9de2de66539a7dbb9abc4352f82 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit adb41bbe00b2b853d4dd26cd9ee77ae5ed541576) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Resurrect data moves in QListAndrei Golubev2021-04-271-0/+58
| | | | | | | | | | | | | | | | | Use the data moves to readjust the free space in the QList, which ultimately fixes the out-of-memory issues caused by cases like: forever { list.prepend(list.back()); list.removeLast(); } Task-number: QTBUG-91801 Task-number: QTBUG-91360 Task-number: QTBUG-93019 Change-Id: Iacff69cbf36b8b5b176bb2663df635ec972c875c Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit a0253f5f0249024580050e4ec22d50cb139ef8d9)
* Inline test cases in tst_qlistAndrei Golubev2021-04-171-598/+157
| | | | | | | | | | | | QList tests have mostly a scheme of: void opInt() { op<int>(); } void opMovable() { op<Movable>(); } void opCustom() { op<Custom>(); } As a drive by, move the leak checking into a separate struct/macro Change-Id: I7cdda3a6c2aa324968aa26594da9f9eafbd49a0a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: Satisfy contiguous_range requirementsFabian Kosmale2021-04-061-0/+20
| | | | | | | | | | | | | | | | | | With C++20, there is a new iterator_category: contiguous_iterator, for containers whose elements are stored contiguously in memory. In Qt 6, QList satisfies this requirement. However, we still need to tell the standard machinery about it. Step one is to mark the iterators as contiguous_iterator; as that exists only in C++20, we have to ifdef accordingly. We also have to ensure that the iterators satisfy pointer_traits by defining element_type due to how contiguous_range is specified. As this runs afoul of LWG 3346, we check for known bad _GLIBCXX_RELEASE versions. Change-Id: I8c134544e694ba937e4d912393eb72fa75b49e3d Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Rename QList test to something meaningfulAndrei Golubev2021-03-181-2/+2
| | | | | | | qtbug_xxxxx is a fairly ambiguous test name Change-Id: I4b407160464c9b8300d3683549b0ede837161e7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Restore pre-Qt6 QList::fill() behaviorAndrei Golubev2021-02-101-7/+63
| | | | | | | | | | | | | | | | | | Somehow QList::fill(t, newSize) introduced a regression in Qt6: when newSize < QList::size() we should resize to the newSize. This is aligned with QVector::fill() in 5.15 and std::vector::assign() While 6.0 is already out, picking it to 6.0.x could save someone who haven't migrated yet as well as fix some accidental bugs in Qt's code [ChangeLog][QtCore][QList] Fixed QList::fill() regression introduced in 6.0: calling fill() with size < current list size wouldn't truncate the list Fixes: QTBUG-91042 Pick-to: 6.0 6.1 Change-Id: Ic166e2c5e42390b61df1030f7c705e344433f7f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Extend alignment of QArrayData to std::max_align_t in allocationAndrei Golubev2021-01-261-1/+29
| | | | | | | | | | | | | | | | | | | | Make stricter alignment requirements for the allocated header This strict alignment allows reallocateUnaligned() to property account for the padding occurring in cases when alignof(QArrayData) < alignof(T) <= alignof(std::max_align_t), which happens to be the case on e.g. 32-bit platforms with specific alignment requirements. This adds 4 bytes (the difference between alignof(std::max_align_t) and sizeof(QArrayData)) of overhead for QString, QByteArray and certain QLists on 32-bit systems. Task-number: QTBUG-90359 Pick-to: 6.0 Change-Id: I8176a4cc79f100ee772b09425e88fe8ff3ae226a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove the qmake project filesJoerg Bornemann2021-01-071-7/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+2
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix crash on reallocateAndGrowMichal Klocek2020-12-211-0/+57
| | | | | | | | | | | | | | | | | | After 6be398 few tests fail/crash with qtcharts. Fix issue on reallocateAndGraw and avoid accessing flags on invalid header. Data::allocate can return invalid header and dataptr, which takes place if capacity is 0. In code before 6be398 clone method checks if header is not null before resetting flags. However after b76fbb4 resetting flags is no longer needed since it is done in allocateGrow. Task-number: QTBUG-89092 Pick-to: 6.0 Change-Id: I2fde781dad7a0694a5f17ab716f647c2e35f4ff0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-1/+1
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Simplify reallocation handling in QListLars Knoll2020-11-171-2/+2
| | | | | | | | | | Have one generic method for detaching and reallocations. Use that method throughout QList to avoid duplicated instantiations of code paths that are rarely used. Change-Id: I5b9add3be5f17b387e2d34028b72c8f52db68444 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement QList::emplaceBack as a proper functionAndrei Golubev2020-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | My endeavours figuring out why QList::append(elem) gives worst performance compared to 5.15 ended up into this commit. After some straightforward fixes, what was left is "everything is uniformly worse" and takes more CPU cycles Introduce emplaceBack implementation as append is quite a special case that could be greatly simplified. This is a "straightforward" part of the optimizations While at it, change append(t) to use emplaceBack(t) For workloads like: QList<int> list; forever { list.append(0); } this gives huge improvement (roughly 30% for 10k+ elements), movable and complex types also get a tiny speedup Task-number: QTBUG-87330 Change-Id: I9261084e545c24e5473234220d2a3f2cd26c2b7f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: don't detach on squeeze when holding raw dataMårten Nordheim2020-09-301-0/+3
| | | | | | | | | To match QString and QByteArray behavior Change-Id: Ifce4a5dee6fc9077e855a24499f11f911e359cf5 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-09-231-1/+1
| | | | | | | | | | | Modify special case locations to use the new API as well. Clean up some stale .prev files that are not needed anymore. Clean up some project files that are not used anymore. Task-number: QTBUG-86815 Change-Id: I9947da921f98686023c6bb053dfcc101851276b5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Support GrowsBackwards prepend in QListAndrei Golubev2020-08-271-8/+23
| | | | | | | | | | | | | Restored previously deleted logic of setting GrowsBackwards flag for prepend-like cases. This should be sufficient to fully enable prepend optimization Fixed QList::emplace to not use implementation detail logic. Updated tests to cover changed behavior and its correctness Task-number: QTBUG-84320 Change-Id: I4aadab0647fe436140b7bb5cf71309f6887e36ab Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Cleanup QTypeInfoLars Knoll2020-08-261-6/+6
| | | | | | | | | | | | | | | Remove QTypeInfo::isStatic, as that's not used anymore in Qt 6. Also remove sizeOf, it's unused, and we have QMetaType for that if required. Remove all typeinfo declaractions for trivial types, as the default template covers them correctly nowadays. Finally set up a better default for isPointer, and do some smaller cleanups all over the place. Change-Id: I6758ed37dfc701feaaf0ff105cc95e32da9f9c33 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-1/+1
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Replace Qt CONSTEXPR defines with constexprAllan Sandfeld Jensen2020-08-141-1/+1
| | | | | | | | Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QList: Add a append(QList &&) overloadMårten Nordheim2020-08-011-0/+195
| | | | | | | | We already had append(const QList &) and now there's an overload taking an rvalue reference. Change-Id: Id2fbc6c57badebebeee7b80d15bb333270fa4e19 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix warning when comparing qsizetype to size_tTor Arne Vestbø2020-07-291-1/+1
| | | | | Change-Id: I4ea7ccb4daf05c735c831964f94c120d179521dd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* CMake: Regenerate testsAlexandru Croitor2020-07-091-2/+2
| | | | | | | | This is in preparation for regenerating them with the new qt_foo prefixed APIs. Change-Id: Iff34932d642b1c0186ee39f952adf3ad367fd602 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Use QList instead of QVector in corelib testsJarek Kobus2020-07-071-1/+1
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic80fde5517aed363f17d0da55cadcc958c3c8895 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Add support for first(n), last(n) and sliced() to QListLars Knoll2020-07-061-0/+30
| | | | | | | | | This keeps the API symmetric with what we have in our string classes. Change-Id: I94c5b39b718ca2472f9ca645e7a42e4314636f67 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of shared null for QByteArray, QString and QVectorLars Knoll2020-07-061-0/+50
| | | | | | | | | | | | | | As a side effect, data() can now return a nullptr. This has the potential to cause crashes in existig code. To work around this, return an empty string from QString::data() and QByteArray::data() for now. For Qt 6 (and once all our internal issues are fixed), data() will by default return a nullptr for a null QString, but we'll offer a #define to enable backwards compatible behavior. Change-Id: I4f66d97ff1dce3eb99a239f1eab9106fa9b1741a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-204-0/+2855
| | | | | | | | | | | | | And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QList an alias to QVectorLars Knoll2019-10-303-2122/+0
| | | | | | | | | | | | | This is almost 100% source compatible with Qt 5. Exceptions are * Stability of references for large or non movable types * taking a PMF for types that are now overloaded with r-value references in QVector * The missing prepend optimization in QVector (that is still planned to come for Qt 6) Change-Id: I96d44553304dd623def9c70d6fea8fa2fb0373b0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>