summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/quuid.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Mark qtbase/src/corelib/plugin files as security-criticalMagdalena Stojek2025-06-041-0/+1
| | | | | | | | | | | | | | | - quuid.cpp parses the string representation of a UUID - qfactoryloader.cpp parses metadata from loaded plugin - qcoffpeparser.cpp, qelfparser_p.cpp and qmachparser.cpp as they are binary object files parsers - qlibrary.cpp, qlibrary_unix.cpp, qlibrary_win.cpp, qpluginloader.cpp are responsible for finding and loading plugins from untrusted locations. Fixes: QTBUG-135193 Change-Id: Ibbcefeab80e7455225ade620bdba45dbc592c581 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
* QUuid: fix qHash() on 64-bit platformsMarc Mutz2025-03-191-4/+3
| | | | | | | | | | | | | | | | | | | | | The old implementation from Qt 5 time only affected the 32 LSB of the result. The upper bits were completely determined by the seed, and the seed alone. To see this, note that all except the seed are at most 32-bit values, and no shifting out of that range occurs, either. Fix by just using qHashBits(), making sure (with a static_assert()) that QUuid has unique object representation (= can be compared for equality using memcmp()). [ChangeLog][QtCore][QUuid] Improved the performance of the qHash() function on 64-bit platforms by populating all bits of the output (was: only lower 32 bits). Amends 55d68a16aafb93aa15bcdbd78892006777b6067a. Pick-to: 6.9 6.8 6.5 Change-Id: Ibf67350f571889fd21e0acc82639c053c0d606b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: mark Version::UnixEpoch as since 6.9Marc Mutz2025-01-081-2/+2
| | | | | | | | | | ... because it is. Amends d89cef439f5c1a58aeff879a12d9a33292764b7f. Pick-to: 6.9 Change-Id: I82cfb386c058a0dda873022377ec91368c71e026 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Bootstrap: remove QUuid and QCryptographicHash: they're now unusedThiago Macieira2024-12-301-6/+2
| | | | | | | | The previous commit removed the one use of QUuid and, through it, QCryptographicHash in one of the three bootstrapped tools. Change-Id: I31b7f9f6aa402709bad7fffd3a65e86be7f6d882 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QUuid: add support for creating UUID v7Ahmad Samir2024-12-071-3/+25
| | | | | | | | | | | | | | | | | | | Thanks to Thiago for the more efficient way of using 12 bits of the sub-milliseconds part of the timestamp. Previously I used the method described in the RFC (value of type double multiplied by 4096). Add a private helper to check the version since now there is a gap in the Version enum values (UUID v6 isn't supported). Drive-by, document Version::Sha1 enumerator. [ChangeLog][QtCore][QUuid] Added support for creating UUID v7 as described in https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7 Fixes: QTBUG-130672 Change-Id: Idfea9fbb12a7f28e25b27b56a3b402799afb4864 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Create qdoc macros for C++ class docs 2.1: qHash()Marc Mutz2024-11-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Add a family of qdoc macros to document the various qHash() overloads we have. This patch does not change the \relates of the qHash() functions, they remain as inconsistent as they have been. Created QTBUG-129815 to clean things up. Since this author expects the \relates to change in the future, there are different \qhash commands, and all except \qhashbuiltin take the class name as an argument, for use in a centrally-choreographed fix for QTBUG-129815. As drive-by's, fix: - missing documentation about Key having to support qHash() in the associative Qt containers - drop noexcept and default arguments from \fn lines that needed to have their argument names changed - move the QStringView overload from qhash.cpp to qstringview.cpp (as it \relates to the former) Fixes: QTBUG-129574 Pick-to: 6.8 6.5 Change-Id: I8e8c2edc27422cbe5823f56baf3a24d7f7050836 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
* QUuid: restore sorting order of Qt < 6.8Thiago Macieira2024-10-211-0/+3
| | | | | | | | | | | | | | | | | | | | This brings back and adapted version of the sorting code that was removed by commit 15f753ca5a60b5273d243f528978e25c28a9b56d. The issue, as shown in the test, is that we store data1, data2, and data3 as native-endian integers, so the bitcasts in the new code cause them to become mangled in little-endian platforms. Since this is a weird behavior and we'll be changing the sorting order in Qt 7 anyway, I've left a warning for us to think about it at the time. [ChangeLog][QtCore][QUuid] Fixed a regression that caused QUuid sorting order to change for some UUIDs, compared to Qt 6.7 and earlier versions. Fixes: QTBUG-130155 Pick-to: 6.8 Change-Id: I5eeb7b36bfc5ed7218e1fffd6a773c582ad0f6f4 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUuid: make more methods constexprIvan Solovev2024-08-301-28/+2
| | | | | | | | | | | | | | | | | Use QT6_{DECL,CALL}_NEW_OVERLOAD mechanism to provide new constexpr overloads for isNull(), variant(), and version(). Move the old methods into removed_api.cpp Use this as an opportunity to optimize the implementaiton of the methods. Also add compile-time checks to the tests. It turns out that QNX compiler fails to compile the default QUuid::isNull() implementation in constexpr context, so rewrite it using a loop. Change-Id: Ia23c81194ea27b369f00ce73b016695600187e46 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: simplify the three-way comparison functions to make them constexprThiago Macieira2024-07-031-39/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While retaining the old sorting order, this allows us to simplify the ifdef'ery and produces much better code. With Clang, an equality check is vmovdqu (%rdi), %xmm0 vpxor (%rsi), %xmm0, %xmm0 vptest %xmm0, %xmm0 sete %al in C++20 mode. GCC generates four 64-bit loads instead of using vectors: movbeq (%rdi), %rax movbeq 8(%rdi), %rdx movbeq (%rsi), %r8 movbeq 8(%rsi), %rcx movq %rdx, %r10 movq %rax, %r11 movq %r8, %rdx movq %rcx, %rax xorq %r10, %rax xorq %r11, %rdx orq %rdx, %rax sete %al (the four MOV in the middle don't seem necessary) For the sorting case, the compilers need to generate extra code because of the check on the variant, something I'm scheduling for removal in Qt 7.0. For long-term sorting code, both GCC and Clang generate four 64-bit load-and-swap-endianness instructions, but Clang for some reason also kept the 128-bit vector code (I'm guessing it's a minor optimization bug that will be corrected in due time). Pick-to: 6.8 Change-Id: I46feca3a447244a8ba19fffd17dceacc8e528c3e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUuid: port createUuidV{3,5}() to QByteArrayViewMarc Mutz2024-05-291-4/+10
| | | | | | | | | | | | | | | | | | | | Requires to mark the existing QString overload as Q_WEAK_OVERLOAD.¹ And since this non-polymorphic class is exported wholesale, we need to involve REMOVED_SINCE here, too. ¹ While QString and QByteArray don't overload well, the new overload set makes calls with QByteArray arguments ambiguous, unless the QString overload is demoted to a weak one. As a drive-by, change the QUuid argument passing from cref to by-value, fixing a Clazy warning. [ChangeLog][QtCore][QUuid] Ported createUuidV3() and createUuidV5() from QByteArray to QByteArrayView, made them noexcept, and fixed various ambiguities in the overload set. Change-Id: I9f71209f2ddb58ace4e15fb68418b1a21d2b3602 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QCryptographicHash: extend hashInto to more than one piece of dataMarc Mutz2024-05-291-7/+7
| | | | | | | | | | | | | | | | This allows use of the noexcept static function in cases where more than one piece of data needs to be hashed, and concatenation of said data would have to allocate memory. Port QUuid to use the new function, allowing to mark the V3 and V5 create functions noexcept. As a drive-by, take QUuid by value in the internal helper function, fixing a Clazy warning. Task-number: QTBUG-125431 Change-Id: I17938f0be44c91085e2aaa5574953f8dceacc990 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QUuid::toRfc4122() with toBytes() where possibleMarc Mutz2024-05-281-1/+1
| | | | | | | | | They're content-equivalent, except that the latter doesn't have to allocate a return value on the heap. Pick-to: 6.7 Change-Id: Ifcae47b487c80c2bac02900f08393b386cfe806c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QUuid, GUID: use new comparison helper macrosTatiana Borisova2024-05-221-40/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | Replace public friend operators operator==(), operator!=(), operator<(), etc of QUuid and GUID with friend methods comparesEqual() / compareThreeWay(). Use Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE, because the (in)equality operators are constexpr. And then we use helper macros, because the other relational operators are not constexpr. Cannot make relational operators constexpr, because it requires to make variant() and isNull() methods constexpr and QT_CORE_INLINE_SINCE. But the experiments show that it does not work with adding constexpr to QT_CORE_INLINE_SINCE. Put relational operators under !QT_CORE_REMOVED_SINCE(6, 8) to prevent an ambiguity. On Windows the metatype for QUuid is created in removed_api.cpp. That leads to an ambiguity, and as a result the compiler fails to create the equals methods of QMetaTypeInterface. This, in turn, leads to the failed comparisons. The usage of !QT_CORE_REMOVED_SINCE(6, 8) solves the problem. Task-number: QTBUG-120304 Change-Id: I640bdeb8f1f7306ba06b9e4193d008cf2bb6dbfb Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Bootstrap: remove QRandomGeneratorThiago Macieira2024-03-131-2/+2
| | | | | | | | | | | The bootstrapped tools really mustn't produce random output (they must always be reproducible exactly). Therefore, ensure we don't need this file. Change-Id: I01ec3c774d9943adb903fffd17b7eb94dbd4be89 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QUuid: de-pessimize QDataStream operatorMarc Mutz2023-10-061-7/+9
| | | | | | | | | | | | | | | | Use a stack buffer instead of a QByteArray to hold the 16 bytes for the QUuid serialisation, replacing toRfc4122() with toBytes() and a memcpy(). As drive-bys, drop the needless cast from char* to uchar* (qToLittleEndian() has void* arguments, so char* is fine) and drop {} around single-line if body. Pick-to: 6.6 Change-Id: I6ffabcf07fc9a730a782e20e113999a0dcf15067 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUuid: convert bswap(Id128Bytes) to a hidden friend of Id128BytesIvan Solovev2023-08-181-0/+48
| | | | | | | | | | | ... and rename it to qbswap(), thus enabling the endian conversions for Id128bytes via q{To,From}{Little,Big}Endian() functions. Found during Qt 6.6 API Review. Pick-to: 6.6 Change-Id: Ie320cee52ec2b9de0aaa112adec8febb7f5b68a2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QUuid: improve documentation regarding the order parameterIvan Solovev2023-08-161-4/+4
| | | | | | | | | | | | Clarify that the order is the expected byte order of the input data. Found during Qt 6.6 API Review. Pick-to: 6.6 Change-Id: Iaa1f5eef22df60676e52197fbcf613f6e9970a3e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove QUuid(quint128) constructor againMarc Mutz2023-08-141-13/+0
| | | | | | | | | | | | | | | | | | | | | | This constructor matches way too many argument types (integral, unscoped enums, FP types), so it's likely to cause mayhem, even if left in as an explicit constructor. We now have a named constructor for the same functionality, so just drop the "unnamed" constructor. "Unnamed" constructors are important when emplacement is more efficient than construction + move, or when implicit conversion is required. Neither is the case here: The named as well as the "unnamed" constructors just copy ten bytes around, and the compiler can optimize those extra copies away just fine. Found in API review. Pick-to: 6.6 Change-Id: I7faafd3ebf522fb2b0e450112fb95d643fece5ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUuid: add a named fromUInt128() ctorMarc Mutz2023-08-111-1/+14
| | | | | | | | | | | | | This makes the API symmetric again (fromBytes()/toBytes(), fromString()/toString(), fromUInt128()/toUInt128()), but also gives us the option to remove the QUuid(quint128), should we so choose, because of its overly-broad argument matching range. Found in API review. Pick-to: 6.6 Change-Id: I91bd2450d62ed565ec3b8e46c875f4983bd9dc73 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: add support for 128-bit integersThiago Macieira2023-05-201-2/+30
| | | | | | | | | [ChangeLog][QtCore][QUuid] Added support for converting between QUuid and quint128, on platforms that offer 128-bit integer types (all 64-bit ones supported by Qt, except MSVC). Change-Id: Id8e48e8f498c4a029619fffd1728c9553e871df5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QUuid: add the ability to specify the byte order for 128-bit IDsThiago Macieira2022-12-161-8/+14
| | | | | | | | Some more modern protocols like Bluetooth LE transmit data in little endian. QtBluetooth will benefit from this. Change-Id: Id8e48e8f498c4a029619fffd1728c94ddd444537 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUuid: add a trivial structure to support exactly 128 bitsThiago Macieira2022-12-161-38/+51
| | | | | | | | This is inspired by QBluetoothUuid's quint128, but with a better name. It also matches systemd's sd_id128. Change-Id: Id8e48e8f498c4a029619fffd172893dc1545adda Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | 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>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-4/+4
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-251-1/+1
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* Doc: Centralize RFC documentation-links in rfc.qdocLuca Di Sera2021-09-161-1/+1
| | | | | | | | | | | | | | | | | | | | In the effort of repairing broken links as per QTBUG-96127, a series of RFC links referring to `tools.ietf.org/html/*` were modified to point to the new address that the site redirected to. To simplify executing a similar task and to diminish the duplication of manually inserted urls, the already existing `rfc.qdoc` file, containing `\externalpage` commands directing to RFC locations, was enhanced with links to all RFCs that were mentioned in the current documentation, so as to aggregate this common category of links. All links pointing to a `ietf` domain inside QDoc documentation blocks were then changed to use the newly provided external-references. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: I2a52eb6aa8c9e346f64ef1a627b039220d9f6c2a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: fix a bunch of qdoc warnings from wrong prototypesVolker Hilsheimer2021-09-031-2/+2
| | | | | | | | | * name method parameters consistently with their declaration * don't document parameters that are not there Pick-to: 6.2 Change-Id: I06ae9fdca357ed29eb7a72802f149eb4914181f4 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QUuid: port to QAnyStringViewMarc Mutz2021-07-301-41/+20
| | | | | | | | | | | | | | | | | Remove the QString/QStringView/QLatin1String/const char* overloads from the API, but not the ABI. As a drive-by, replace a use of QStringView::left() by truncate(), as suggested by a comment. [ChangeLog][QtCore][QUuid] The from-string constructor and the fromString() function now take QAnyStringView (was: overload set with a subset of QString, QByteArray, const char*, QLatin1String, QStringView each). Change-Id: If7fa26cfbef9280480c78b669d9f5f14118995ed Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: port fromRfc4122() to QByteArrayViewMarc Mutz2021-07-281-15/+14
| | | | | | | | | Remove the QByteArray overload from the API, but not the ABI. Adapt callers. Change-Id: I88aa09cbca3b89d0b249ce336ebe49c4b352c9e1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Whitespace cleanup in corelib/ mimetypes, plugin and threadAllan Sandfeld Jensen2020-10-211-4/+4
| | | | | | | Done with selective application of clang-format Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUuid: merge toString() overloads and toByteArray() overloadsEdward Welbourne2020-09-141-89/+1
| | | | | | | | | | In each case, simply give WithBraces as default for mode, since that's what _q_uuidToHex() used internally. Task-number: QTBUG-85700 Change-Id: I9f6fddb259703917129d4be742bbdd2eb1647f44 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Change qHash() to work with size_t instead of uintLars Knoll2020-04-091-1/+1
| | | | | | | | | | | This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-8/+8
| | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: replace null and nullptr with \nullptr in documentationChristian Ehrlicher2019-02-181-1/+1
| | | | | | | Replace null and '\c nullptr' with \nullptr in the documentation. Change-Id: Ib9e0cfc2eb2830b213e6523773603d56180b0998 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Merge remote-tracking branch 'origin/dev' into 5.11Liang Qi2018-02-101-3/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qvarlengtharray.qdoc src/corelib/tools/qvector.qdoc Resolved documentation changes in favor of 017569f702b6dd0, which keeps the move overloads along with its const-ref sibling. Change-Id: I0835b0b3211a418e5e50defc4cf315f0964fab79
| * Support for LTTNG and ETW tracingRafael Roquetto2018-01-281-3/+1
| | | | | | | | | | | | | | | | | | | | This commit introduces minimal support for instrumentation within Qt. Currently, only LTTNG/Linux and ETW/Windows are supported. Change-Id: I59b48cf83acf5532a998bb493e6379e9177e14c8 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QUuid: add a way to get the string form without the bracesThiago Macieira2018-02-031-7/+112
|/ | | | | | | | | | | | | | While we're at it, add a way to get it without the dashes too. I'm calling it "id128", as in "128-bit ID", as seen in journald's sd_id128_t type and the sd_id128_xxx() API. [ChangeLog][QtCore][QUuid] Added a parameter to both toString() and toByteArray() to allow controlling the use or not of the braces and dashes in the string form. Change-Id: I56b444f9d6274221a3b7fffd150cde706cfc5098 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QRandomGenerator: add system() and global()Thiago Macieira2017-10-291-1/+1
| | | | | | | | | | | | | | | | | Right now,this does really nothing. This commit is just to allow us to transition the other modules (besides qtbase) to use the syntax that will become the API. I've marked three places to use the system CSPRNG: 1) the QHash seed 2) QUuid 3) QAuthenticator I didn't think the HTTP multipart boundary needed to be cryptographically safe, so I changed that one to the global generator. Change-Id: Ib17dde1a1dbb49a7bba8fffd14ecf1938bd8ff61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUuid, QHttpMultipart and QHash: use QRandomGeneratorThiago Macieira2017-06-121-88/+10
| | | | | | | | | QRandomGenerator can produce more than 31 bits of data. And it uses /dev/urandom for us on Unix, so QHash does not need to duplicate that part. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b52a0d91f179eb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUuid: add fromString(QStringView/QLatin1String)Marc Mutz2017-04-201-62/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As for the formatting code, de-duplicate the parsing code by only parsing char*s, converting QChars to Latin-1 first in a small buffer. The QUuid(const char*) ctor performed no length checking, relying instead on the checks performed within _q_uuidFromHex(), which includes an implicit check for premature end (because NUL is not a valid token for the parser). The (QString) and (QByteArray) ctors did perform length checking. To the extent possible, this is removed, since it is handled by _q_uuidFromHex(). Failure cases need not be optimized. Only the QLatin1String overload needs to do some checking, because views in general are not NUL-terminated. The QStringView overload can just append a NUL when it converts to Latin-1. The only check I added to _q_uuidFromHex() is that for src == nullptr. It would otherwise be duplicated in several callers. While touching the internal functions, port to passing and returning by value. Saves 1.6KiB in text size on optimized GCC 6.1 Linux AMD64 builds, even though we added new API. Port some users to the new functions. Expand fromString() test. [ChangeLog][QtCore][QUuid] Added fromString(QStringView/QLatin1String). Change-Id: I519339419129550c86e0ea80514865cd6a768f5d Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUuid: de-duplicate uuid → string formattingMarc Mutz2017-04-191-28/+31
| | | | | | | | | | | | | The code was duplicated for QChar and char characters. Keep only the char version, and use QString::fromLatin1() to convert to QString. This does not perform more allocations. It just copies 38 bytes more than before. Saves 788B in text size on optimized GCC 6.1 Linux AMD64 builds. Change-Id: I1a65c8128eb2097e11527961618d54ea362e1b80 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use static initialization for QBasicAtomicsMarc Mutz2017-02-161-1/+1
| | | | | | | | | | | | | A default-constructed static QBasicAtomicInt at function scope will be dynamically initialized. It will still be zero-initialized, but at least GCC adds guard variables for such objects. When using aggregate initialization, the guard disappears. Amends 04d6495bf773a6bb0d4fa6980df22d3b81a605b0. Change-Id: Id9335cffdd43094cafb231fdde2523d013abe1d6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make some atomic counters zero-basedMarc Mutz2017-02-151-2/+2
| | | | | | | | | | | | | | A variable of static storage duration that is not zero-initialized takes up space in the DATA segment of the executable. By making the counters start at zero and adding the initial value afterwards, we move them over to the BSS segment, which does not take up space in the executable. Wrap atomics used across function boundaries into small functions, to avoid code duplication and to increase readability. Change-Id: Ida6ed316ecb8fe20da62a9577161349e14de5aed Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix/adapt the uses of {to,set,from}Time_t in the qtbase source codeThiago Macieira2016-07-061-2/+2
| | | | | | | | | Move those to the equivalent {to,set,from}SecsSinceEpoch(), except for the cases that did QDateTime::currentDateTime{,Utc}().toTime_t. Those are best implemented with QDateTime::currentSecsSinceEpoch(). Change-Id: Ib57b52598e2f452985e9fffd145a366c92cfda20 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDateTime: introduce {to,from,set,current}SecsSinceEpochThiago Macieira2016-06-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | These new functions use a 64-bit integer in the API, instead of the broken 32-bit unsigned integer that the previous xxxTime_t functions used. That was a design flaw when the API was introduced back in Qt 4.2, so I'm deprecating the API and slating it for removal in 6.0. The changes to qfilesystemmetadata_p.h and quuid.cpp are necessary to build the bootstrap library. The rest of the adaptation to the new API will come in the next commit. [ChangeLog][QtCore][QDateTime] Introduced toSecsSinceEpoch, fromSecsSinceEpoch and setSecsSinceEpoch functions, which use 64-bit integers to represent the number of seconds. [ChangeLog][QtCore][QDateTime] The toTime_t, fromTime_t and setTime_t functions are deprecated and will be removed in Qt 6.0. For new code, use the equivalent functions with "SecsSinceEpoch" in the name, or the equivalent ones with millisecond accurancy that have existed since Qt 4.7. Change-Id: Ib57b52598e2f452985e9fffd145a355d0e7ff48d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* darwin: Move conversion function documentation to function definitionTor Arne Vestbø2016-05-031-33/+0
| | | | | | | It's easier to maintain the function and the docs when they live together. Change-Id: I1e047b4ac1eb61a36849188da560dd899e05509f Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/devJędrzej Nowacki2015-11-051-4/+4
|\
| * Doc: fixed broken linksNico Vertriest2015-11-041-2/+2
| | | | | | | | | | | | Task-number: QTBUG-43810 Change-Id: If6ac30a0407731b31e8aaad28d33e2bb49dee6f3 Reviewed-by: Martin Smith <martin.smith@digia.com>
| * Convert some QDateTime::currentDateTime() to currentDateTimeUtc() (I)Marc Mutz2015-10-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The latter is much faster as it doesn't have to deal with time zones. This change handles the trivial ones: Either the call to currentDateTime() is immediately followed by a call to toUTC() or toTime_t(). The latter is much faster on UTC QDateTimes, too. Credits to Milian Wolff, from whose QtWS15 talk this advice is taken. Change-Id: I872f5bbb26cbecedc1e5c0dbee4d5ac2c6eb67ee Reviewed-by: Milian Wolff <milian.wolff@kdab.com>