summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydatapointer.h
Commit message (Collapse)AuthorAgeFilesLines
* QArrayData/Pointer: s/QPair/std::pair/Marc Mutz2023-12-131-1/+1
| | | | | | | | | | 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>
* qarraydatapointer: use use std::exchange moreAnton Kudryavtsev2023-11-011-4/+3
| | | | | | | to simplify code Change-Id: I7fc6dd92922eb30a16260544223c1dbfc3162188 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QBA: add lvalue and rvalue overloads to first/last/sliced/choppedThiago Macieira2023-10-251-0/+20
| | | | | | | | | | | | Those ought to have been the original implementation, when they were added in commit 38096a3d7040edac4f769270d2402ff4e39d7694, for Qt 6.0. Because these classes are exported, we need to provide the previous only implementations for MSVC. All other compilers would provide inline or emit local, out-of-line copies. Change-Id: Ifeb6206a9fa04424964bfffd178836a2ae56157d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QArrayDataPointer: add an allocating constructorThiago Macieira2023-10-251-2/+9
| | | | | | | | It's by far the most common use, so having to call two things is just cumbersome. Change-Id: I79e700614d034281bf55fffd178f454c4e31929e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QArrayDataPointer: remove Q_CHECK_PTR in assign(it, it) againDennis Oberst2023-09-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Mark all remaining RAII/smart pointer class ctors [[nodiscard]]Marc Mutz2023-06-221-0/+6
| | | | | | | | | | | | | | | | | | | ... like QUIP-0019 suggests. The main problem here is finding these classes. We don't have markup for RAII classes, so I had to find them by name. This patch is based on the output of git grep -we Q[A-Z0-9a-z_]+er extracting the matches and piping them through sort -u, then removing a lot of suffixes like Manager and Handler, then visually inspecting the remaining list. Task-number: QTBUG-104164 Pick-to: 6.6 Change-Id: I59b18d8d0a0237fcc11047857adc39b984ad7fcb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QArrayDataPointer: fix optional projection in assign()Dennis Oberst2023-05-311-1/+7
| | | | | | | | | | | | | | | | | When a custom projection is used in the assign() function, there is a problem with the optimization step at: dst = std::uninitialized_copy(first, last, dst); The issue arises because this copy doesn't respect the custom projection. To address this problem, we need to ensure that the optimization is only applied when using the identity projection. Amends: 7ca633d9a82f90e5bba5e12ba923bfb0a257af63. Change-Id: I912525c716333ee2c22c419f2bf70201086c5635 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QArrayDataPointer: add missing std::invoke call to projectionDennis Oberst2023-05-301-4/+5
| | | | | | | | | | | | To ensure the correct invocation of the projection function, this patch introduces the usage of std::invoke for all accesses to it. This modification expands the coverage to include cases where the callable object is a pointer to a member function. Amends: 7ca633d9a82f90e5bba5e12ba923bfb0a257af63. Change-Id: If666012d785ac74c8e856ea9be2a46b3307c8a06 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QArrayDataPointer: add missing Q_CHECK_PTR check in assign()Dennis Oberst2023-05-301-0/+2
| | | | | | | | | | | | The previous implementation of iterator-assign did not include a check for the return value of QArrayData::allocate(~), which returns a nullptr on failure. Amends: bbbe5f45c4d354ef977d4e09459ef5ae4d6db0da. Change-Id: I219e63ecd6de4225364d9c3dd2006ddbbe47068f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QList: re-use the prepend buffer, if any, on assign()Marc Mutz2023-05-171-4/+43
| | | | | | | 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>
* QArrayDataPointer: add a C++20 ranges-style optional projection to assign()Marc Mutz2023-05-161-4/+6
| | | | | | | | | | | | This will be useful for implementing QString::assign(), which otherwise has the problem that it's d_ptr is based on char16_t, but it's assign() is supposed to be able to deal with iterators whose value_type returns QChar. Task-number: QTBUG-106198 Change-Id: I87882bf749b4e21b7b32391167962d3e6bae9983 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: add STL-style assign()Dennis Oberst2023-05-161-0/+47
| | | | | | | | | | | | | | | 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>
* QArrayDataPointer: skip deallocate detourFabian Kosmale2023-03-231-1/+1
| | | | | | | | | | We never made use of it since its introduction in 5.0, and calling free directly reduces the size of libQtCore by roughly ~100kb. Change-Id: I7dbdac83c82fa38d1833a4677fc83ebe809a11ef Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QContainerTools: add q_points_into_range overloadAhmad Samir2022-12-111-1/+1
| | | | | | | | | Looking at the use-cases of the already existing q_points_into_range overload, all of them can be ported to the new one (i.e. all of them were using range [begin, end)). Change-Id: I4bfdd68271512b88a9800a16237ff967a367eaeb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+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>
* QArrayDataPointer: don't overload qSwap(), provide ADL-swap()Marc Mutz2022-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is our wrapper around using std::swap; swap(lhs, rhs); it needn't and shouldn't be overloaded. ADL swap() should be, though, so qSwap(), std::ranges::swap() and all the other adl_swap()s out there all find the optimized version. Qt 5.15 has it correct, Qt 6 wrong. Fix it. Can't pick to 6.2 because, while backwards-source-compatible, because the generic qSwap() template provides the name for both qualified and unqualified calls, it's not forwards-source-compatible: A new user of ADL swap // compile error w/o `using std::swap`, pessimization otherwise: swap(dp1, dp2); would break or performance-regress when going back to an older version. Pick-to: 6.3 Change-Id: I725949a4aa9ae438a182b4b7552ff2dced767e2f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QString::toLatin1_helper_inplace: simplify the codeThiago Macieira2022-01-171-0/+22
| | | | | | | | | Hot function, so help the compiler out. In particular, this removes any touch to the ref count, so there are no atomic operations or dead code leading to memory allocations and deallocations. Change-Id: I0e5f6bec596a4a78bd3bfffd16c9a0fbd8dd2c12 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QList: do some minor cleanups in the internal codeAndrei Golubev2021-05-271-1/+0
| | | | | Change-Id: I7e502e4d2fa5af94c20e7da62d1c06597b6b16a7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QArrayData: store the right flag type, not an intGiuseppe D'Angelo2021-05-171-1/+1
| | | | | | | | There's no reason to be storing `int` in the array data header and then using it as a QFlags. Just store the QFlags. Change-Id: I78f489550d74d15a560dacf338110d80a7ddfdd2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Resurrect data moves in QListAndrei Golubev2021-04-271-13/+121
| | | | | | | | | | | | | | | | | 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)
* Fix crash on reallocateAndGrowMichal Klocek2020-12-211-1/+1
| | | | | | | | | | | | | | | | | | 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>
* Move the iterator from QTypedArrayData to QListLars Knoll2020-11-171-8/+6
| | | | | | | | | | The low level implementation does not use it at all, so there's no point having the iterator in QTypedArrayData. Having it in QList removes and indirection and will lead to clearer error messages. Change-Id: I4af270c3cdb39620e5e52e835eb8fe1aa659e038 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Remove destructor calls from insert()Lars Knoll2020-11-171-3/+0
| | | | | | | | | | | | | | | | | | QList::insert() should never need to call a destructor. This requires that we construct the new items in the list in order and increment the size each time we constructed a new item. Not having a code path that potentially calls destructors should avoid the generation of lots of additional code for those operations. In addition, the forward and backwards code paths are now unified and only require somewhat different setup of some variables at the start. This gives us strong exception safety when appending one item, weak exception safety in all other cases (in line with std::vector). Change-Id: I6bf88365a34ea9e55ed1236be01a65499275d150 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Simplify reallocation handling in QListLars Knoll2020-11-171-42/+46
| | | | | | | | | | 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>
* Smaller code cleanups in QListLars Knoll2020-11-171-3/+3
| | | | | | | | | | Some cosmetics, but also some optimizations where we avoid a temporary copy, or calling detach() twice. Change-Id: I26803fdecf943ed9fab9baf58124091c7cebe1f3 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid crashes when calling squeeze()Lars Knoll2020-11-091-1/+1
| | | | | | | | | Avoid crashes when calling squeeze() on a QList with non zero capacity but zero size. Change-Id: Id470b2d52266a345b94bc3dc5483f4668fbb57dc Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename AllocationPosition enum and its membersLars Knoll2020-11-041-5/+5
| | | | | | | Use GrowsAt* and GrowthPosition as that is clearer. Change-Id: I3c173797dec3620f508156efc0c51b4d2cd3e142 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce QADP::reallocateGrow()Andrei Golubev2020-11-041-0/+19
| | | | | | | | | | | | | | Added realloc() code path to QMovableArrayOps Implemented fast realloc() based growing for QADP and used it in QList::emplaceBack. This gives quite a bit of speedup and shows better results than 5.15 at 100k+ iterations of "list.append(elem)", meanwhile also closing a gap between movable types Task-number: QTBUG-87330 Change-Id: I42fc182ecd93c85600dac622385152fc57735da8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up out allocation handlingLars Knoll2020-11-041-42/+11
| | | | | | | | | | Get rid of the allocation options inside the flags field of QArrayData, they are really a completely separate thing. Change-Id: I823750ab9e4ca85642a0bd0e471ee79c9cde43fb Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid expensive iterator calculations in append()Lars Knoll2020-11-041-0/+31
| | | | | | | | | | | | | Avoid moving data inside the array to create free space at one end. This is a performance bottleneck, as it required quite a lot of calculations for every insert. Rather reallocate and grow in this case, so we only need to do expensive work when we reallocate the array. Change-Id: Ifc955fbcf9967c3b66aa2600e0627aac15f0c917 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QArrayDataPointer: redesign (and simplify) growth policyAndrei Golubev2020-11-041-15/+10
| | | | | | | | | | | | | | | | | | | | | | | | It looks like we can drastically simplify the way QADP grows without sacrificing much: 1. append-only use cases should have the same performance as before 2. prepend-only use cases should (with the help of other commits) get additional performance speedup 3. mid-insertion is harder to reason about, but it is either unchanged or benefits a bit as there's some free space at both ends now 4. mixed prepend/append cases are weird and would keep excess free space around but this is less critical and overall less used AFAIK Now, QList would actually start to feel like a double-ended container instead of "it's QVector but with faster prepend". This commit should help close the performance gap between 6.0 and 5.15 as well As a drawback, we will most likely have more space allocated in mixed and mid-insert cases. This needs to be checked Task-number: QTBUG-86583 Change-Id: I7c6ede896144920fe01862b9fe789c8fdfc11f80 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QVersionNumber and QArrayDataPointer comparisons hiddenAllan Sandfeld Jensen2020-10-271-12/+10
| | | | | Change-Id: I8de0407843103b49877621534c14046e3a7d1b2f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Refine QADP::pass_parameter_by_value evaluationAndrei Golubev2020-10-241-1/+4
| | | | | Change-Id: I8327ab3eb2503228448af59098146e062d4b90d3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QADP capacity functions use qsizetype instead of size_tAndrei Golubev2020-10-081-3/+3
| | | | | | | | | | | | | | | Change types returned and accepted by capacity-related QArrayDataPointer functions to qsizetype: 1) QArrayData (underlying d-ptr) works with qsizetype 2) QArrayDataPointer::size is of type qsizetype 3) All higher level classes that use QADP (e.g. containers) cast capacity to qsizetype in their methods Additionally, fixed newly appeared warnings through qtbase Change-Id: I899408decfbf2ce9d527be7e8b7f6382875148fc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Centralize the implementation of move assignment operatorsGiuseppe D'Angelo2020-10-031-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the moment we have two main strategies for dealing with move assignment in Qt: 1) move-and-swap, used by "containers" (in the broad sense): containers, but also smart pointers and similar classes that can hold user-defined types; 2) pure swap, used by containers that hold only memory (e.g. QString, QByteArray, ...) as well as most implicitly shared datatypes. Given the fact that a move assignment operator's code is just boilerplate (whether it's move-and-swap or pure swap), provide two _strictly internal_ macros to help write them, and apply the macros across corelib and gui, porting away from the hand-rolled implementations. The rule of thumb when porting to the new macros is: * Try to stick to the existing code behavior, unless broken * if changing, then follow this checklist: * if the class does not have a move constructor => pure swap (but consider ADDING a move constructor, if possible!) * if the class does have a move constructor, try to follow the criteria above, namely: * if the class holds only memory, pure swap; * if the class may hold anything else but memory (file handles, etc.), then move and swap. Noteworthy details: * some operators planned to be removed in Qt 6 were not ported; * as drive-by, some move constructors were simplified to be using qExchange(); others were outright broken and got fixed; * some contained some more interesting code and were not touched. Change-Id: Idaab3489247dcbabb6df3fa1e5286b69e1d372e9 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-1/+1
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update allocation interface of QArrayDataPointerAndrei Golubev2020-08-271-0/+6
| | | | | | | | | | | | | Added overload to allocGrow that figures the capacity to allocate from the newSize argument passed. This is useful in QList (and likely in other places) Fixed QArrayPodOps::reallocate as a drive by: don't call memmove when it is not needed Task-number: QTBUG-84320 Change-Id: I67efe55a60efaf3ab6057b0249d6a446e04a09e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support GrowsBackwards flag in QArrayDataPointerAndrei Golubev2020-08-271-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | Introduced allocation function in QArrayDataPointer with interface similar to QArrayData::allocate that supports growing strategies. This func is used instead of the original in cases when prepend-aware storage is needed. Tried to follow Qt5 QList policy in terms of space reservation Updated QPodArrayOps::reallocate to be aware of growing shenanigans. It doesn't look like a perfect solution but it is rather close and similar to what Qt6 QList is doing when not growing (e.g. reserve/squeeze) Added initial QCommonArrayOps with helper function that tells when reallocation is preferable over just using the insert-like operation. This comes up later on when GrowsBackwards policy is properly supported in operations Essentially, 2/3 main data management blocks for prepend optimization are introduced here. The last one being a generalized data move that is done instead of reallocation when existing free space is not enough Task-number: QTBUG-84320 Change-Id: I9a2bac62ad600613a6d7c5348325e0e54aadb73d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QXmlStreamReader from QStringRef to QStringViewKarsten Heimrich2020-08-191-0/+1
| | | | | | | | | | | Use the new QtPrivate::XmlString class as the container holding the string data internally. It basically a "QStringRef lite", purely used in the implemntation. This replaces all usages of QStringRef in the parser. Fixes: QTBUG-84318 Change-Id: I557bbc6831301866602586d11d53283affd034a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QArrayDataPointer::freeSpace*() functionsAndrei Golubev2020-08-181-1/+15
| | | | | | | | | | | | | Added functions that tell how much free space is available at the beginning and at the end of the storage Updated preconditions of operations to use freeSpace* functions Also, changed casts uint(this->size) to size_t(this->size) Task-number: QTBUG-84320 Change-Id: Iad94c1060a00f62068da9d1327e332a00d4f4109 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QArrayDataPointer: use move and swap in move assignmentGiuseppe D'Angelo2020-07-101-1/+2
| | | | | | | | | Not plain swap; QADP does not hold just memory but arbitrary state (depending on T). Change-Id: I3560577e4109607a51b2c72b67e22e38813977b3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QArrayDataPointer::size a qsizetypeLars Knoll2020-07-061-6/+6
| | | | | | | | This is a next step towards making QList, QString and QByteArray able to deal with large sizes. Change-Id: Icad49b33f503401ac4912678b2f88584c6f91a63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a couple of noexceptLars Knoll2020-07-061-6/+6
| | | | | Change-Id: I993da2094482092540388ee72be3262bac94fad7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of QArrayData::sharedNull()Lars Knoll2020-07-061-3/+0
| | | | | | | | Remove the last places where those got used and avoid allocations when we resize to 0. Change-Id: Ib553f4e7ce7cc24c31da15a55a86d18bdf1cc5c3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify Q_ARRAY_LITERALLars Knoll2020-07-061-2/+17
| | | | | | | And clean up some unused pieces of code. Change-Id: I285b6862dc67b7130af66d3e08f652b1a56b990e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Get rid of shared null for QByteArray, QString and QVectorLars Knoll2020-07-061-34/+27
| | | | | | | | | | | | | | 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 the reallocate() method from QArrayDataPointer to the Ops classLars Knoll2020-07-021-6/+0
| | | | | | | | | And only implement it for QPodArrayOps, as that's the only case where we should be using it. Change-Id: If48f3e4b142c322d3451309d6d1cf68aee569ea2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* MSVC: Fix integer conversion warnings in containersFriedemann Kleint2020-01-031-2/+2
| | | | | | | | | | | | Add some casts, fixing warnings like: src/corelib/text/qbytearray.h(490): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/text/qstring.h(1045): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/tools/qarraydatapointer.h(80): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/tools/qarraydatapointer.h(75): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data src/corelib/text/qbytearray.h(490): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data Change-Id: I221db4d5b660224f0fc1869248802c496db1b91c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Convert QString to use QArrayDataPointerLars Knoll2019-12-161-0/+2
| | | | | | | | | | | | We're now using the same infrastructure for QVector, QString and QByteArray. This should also make it easier to remove the shared null in a follow-up change. Change-Id: I3aae9cf7912845cfca8e8150e9e82aa3673e3756 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>