summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qduplicatetracker_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Opt out of standard library memory_resource on macOS < 14 and iOS < 17Tor Arne Vestbø2023-06-081-1/+1
| | | | | | | | | | | | | | | | | | Although the header is available, and the compiler reports that the standard library supports memory_resource, the feature is only available on macOS 14 and iOS 17, as reported by https://developer.apple.com/xcode/cpp/ As long as our deployment target is lower we can't unconditionally use this feature. It's not clear whether the expectation is that consumers of the standard library on these platforms will have to runtime check their uses of these APIs. Pick-to: 6.6 6.5 Task-number: QTBUG-114316 Change-Id: I50c1425334b9b9842b253442e2b3aade637783ea Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace qExchange with std::exchangeMarc Mutz2022-10-071-2/+2
| | | | | | | | | | | | | None of these users require C++20 constexpr or C++23 noexcept, the only remaining difference between std::exchange and qExchange. This leaves a single qExchange() user, in QScopedValueRollback, that requires the constexpr version, only available from C++20, and thus remains unported. Task-number: QTBUG-99313 Change-Id: Iea46f6ed61d6bd8a5b2fd9d9ec4d70c980b443a2 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>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-241-1/+1
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QDuplicateTracker: add clear()Thiago Macieira2021-11-111-0/+5
| | | | | | | | I'll need it in QFactoryLoader. Pick-to: 6.2 Change-Id: Ice04365c72984d07a64dfffd16b47f68d25252b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove checks for C++ standard versions C++17 and belowIevgenii Meshcheriakov2021-10-011-1/+1
| | | | | | | | | | | Qt requires a compiler that support C++17 thus __cplusplus is always 201703L or higher. This patch removes checks for __cplusplus value that always succeed. Change-Id: I4b830683ecefab8f913d8b09604086d53209d2e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QDuplicateTracker: bring back appendTo() &&Marc Mutz2021-07-271-1/+19
| | | | | | | | | | | | | | This reverts commit c19695ab953c979f15bbc72c4f4a453e9a114cf6. Just because QSet has limited API doesn't mean we can't provide this in an efficient way for std::unordered_set :P Added tests. Pick-to: 6.2 Change-Id: I4f8f0e60c810acdc666cf34f929845227ed87f3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QDuplicateTracker: accept the number of elements to reserve as a ctor argumentMarc Mutz2021-07-141-0/+8
| | | | | | | | | | | | This prevents us from first reserve()ing Prealloc elements, and then possibly reserve()ing a larger number, which leaves the first bucket list's memory unused. Consequently, deprecate reserve(). Change-Id: Ifc0a5a021097f4589557e7b5e45d9d0892797ade Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: port reserve() from int to qsizetypeMarc Mutz2021-07-141-1/+1
| | | | | | | | Was missed in the int -> qsizetype port for Qt 6.0. Pick-to: 6.2 6.1 Change-Id: I1ae8190601f2e1a1bc02a736c12230a9c71acb18 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: simplify the implementationMarc Mutz2021-07-131-21/+21
| | | | | | | | ...by providing std-compatible insert() functions via a local subclass of QSet, reducing the #ifdef'ery somewhat. Change-Id: Ib532a866b47b82e8e3b9f199e8d1e01a87ed016d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: reserve() for at least Prealloc elementsMarc Mutz2021-07-131-2/+3
| | | | | | | | | | We have space for so many elements, so reserve()ing anything less makes no sense. Pick-to: 6.2 6.1 5.15 Change-Id: I84d692b10a6a491c37661f84aa3fdd9af43d71e5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: fix the static buffer size calculationMarc Mutz2021-07-131-1/+7
| | | | | | | | | | | Instead of just sizeof(T), we, of course, also need to take the support structure into account, to wit: the bucket list and, in the node, the next pointer and the stored hash value. Pick-to: 6.2 6.1 5.15 Change-Id: I8227a95c49e316aacf3d4efd8f6170ea3bea1cf0 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce QHashSeed and switch to size_t seedsThiago Macieira2021-05-231-1/+1
| | | | | | | | | | | Commit 37e0953613ef9a3db137bc8d3076441d9ae317d9 added a to-do, but we can actually change the type, since we've documented since Qt 5.10 that setting a non-zero value (aside from -1) with qSetGlobalQHashSeed was not allowed. Storing a value to be reset later is simply not supported. Change-Id: Id2983978ad544ff79911fffd1671f7b5de284bab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Use __has_* instead QT_HAS_*JiDe Zhang2021-05-211-1/+1
| | | | | | | | Use __has_include instead QT_HAS_INCLUDE Use __has_feature instead QT_HAS_FEATURE Change-Id: If9b0af1f4386f7bcae6ca2fb911ffaba422750dd Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QDuplicateTracker: store the current seed in the hasherThiago Macieira2021-04-221-1/+2
| | | | | | | | It's allowed to change asynchronously by another thread. Pick-to: 6.1 6.0 5.15 Change-Id: I6cdea00671e8479b9c50fffd167836a08a42cc1d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QDuplicateTracker: allow usage of qHashGiuseppe D'Angelo2020-12-031-1/+9
| | | | | | | | | | The codepath using unordered_set forced the usage of std::hash, which isn't provided by many Qt types. Instead, use the brand new helpers in QHash that dispatch to qHash with a fallback on std::hash. Change-Id: I9185fe9c52de05c470afe7466007591977e65bb1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDuplicateTracker: remove the appendTo && overloadMårten Nordheim2020-12-021-8/+1
| | | | | | | | | | | As a requirement for unordered_set (and QSet) both "iterator" and "const_iterator" are const, so we cannot reassign or move the key. That means this overload is no different to the const & overload, so we can just remove it. Pick-to: 6.0 Change-Id: Ia14dccf7f610967649bab38161ce6d963509316b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Replace Q_REQUIRED_RESULT with [[nodiscard]]Allan Sandfeld Jensen2020-09-251-2/+2
| | | | | | | It was already used many places directly making the code inconsistent. Change-Id: I3b14bc6c333640fb3ba33c71eba97e78c973e44b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QSsl: port a local QStringList to QDuplicateTrackerMarc Mutz2020-06-081-0/+14
| | | | | | | | | | | | Apart from a more fitting, minimal, API, QDuplicateTracker also transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or at least reduce, memory allocations. The code is the first user of the collected data, so make that available by adding QDuplicateTracker::appendTo(Container&) methods. Change-Id: Ibd8810c0070db7e6b3ead6d6a569facdab88b646 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDuplicateTracker: add rvalue overloadMarc Mutz2020-05-051-0/+12
| | | | | | | We have at least one user that only ever passes rvalues. Change-Id: I3f190b8d074e40a23c52e791635c9a1c45ba00ab Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QStringList: use local storage in removeDuplicates()Marc Mutz2020-01-261-0/+94
If available, use a C++17 std::pmr::unordered_set with a monotonic buffer resource and a 256-byte stack buffer to avoid the per-element allocations of QSet. Results on my machine: RESULT : tst_QStringList::removeDuplicates():"empty": - 0.00014 msecs per iteration (total: 74, iterations: 524288) + 0.000031 msecs per iteration (total: 66, iterations: 2097152) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.00": - 0.00043 msecs per iteration (total: 57, iterations: 131072) + 0.00013 msecs per iteration (total: 69, iterations: 524288) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.50": - 0.00049 msecs per iteration (total: 65, iterations: 131072) + 0.00032 msecs per iteration (total: 85, iterations: 262144) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.66": - 0.00057 msecs per iteration (total: 75, iterations: 131072) + 0.00039 msecs per iteration (total: 52, iterations: 131072) RESULT : tst_QStringList::removeDuplicates():"short-dup-0.75": - 0.00064 msecs per iteration (total: 85, iterations: 131072) + 0.00048 msecs per iteration (total: 63, iterations: 131072) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.00": - 0.083 msecs per iteration (total: 85, iterations: 1024) + 0.039 msecs per iteration (total: 80, iterations: 2048) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.50": - 0.11 msecs per iteration (total: 58, iterations: 512) + 0.078 msecs per iteration (total: 80, iterations: 1024) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.66": - 0.13 msecs per iteration (total: 70, iterations: 512) + 0.10 msecs per iteration (total: 53, iterations: 512) RESULT : tst_QStringList::removeDuplicates():"long-dup-0.75": - 0.16 msecs per iteration (total: 86, iterations: 512) + 0.13 msecs per iteration (total: 69, iterations: 512) When interpreting the data, take into account that each iteration contains _also_ a deep copy of the QStringList d/t the detach from 'input'. The pattern is used elsewhere in Qt, so I've put the class that implements the seen set into a private header file and used in some other places I found. Change-Id: I1f71a82008a16d5a3818f91f290ade21d837805e Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>