summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringliteral.h
Commit message (Collapse)AuthorAgeFilesLines
* QStringLiteral: suppress the clang-tidy warning about const_castThiago Macieira2021-08-041-4/+14
| | | | | | | | | | We can't add the comment inside the macro, so we solve the problem by adding an extra level of indirection. Pick-to: 6.2 Change-Id: Ib8fbfcfeb48a49ca945dfffd169829b3610f6a34 Reviewed-by: Rui Oliveira Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Drop qunicodecharGiuseppe D'Angelo2020-08-141-6/+1
| | | | | | | | | It's unused except in the definition of QStringLiteral, where we can just use char16_t. The static_assert can also go as it's already checked in qglobal.cpp. Change-Id: I06e8a87b4dea1582cd84957efca1b8ad0d2e0266 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Get rid of shared null for QByteArray, QString and QVectorLars Knoll2020-07-061-12/+3
| | | | | | | | | | | | | | 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>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-1/+1
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QString: throughly port internals to char16_tMarc Mutz2020-05-191-3/+3
| | | | | | | | | | This includes allocating QString data as char16_t instead of ushort. This isn't the end of the port, but an important milestone: the traditional foldChar() functions are now all unused. Change-Id: I766bebc2d70b6972e2045d3474c7f5770f4676d9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Drop the deprecated QStringViewLiteralGiuseppe D'Angelo2020-05-131-4/+0
| | | | | Change-Id: I6e6643b4c7cbcd43c495c332de0d6874856b9528 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-04-271-1/+1
|\ | | | | | | | | | | | | Conflicts: src/corelib/text/qstringliteral.h Change-Id: I1665af3ce537471b249def5e080b39bd4105189e
| * QStringLiteral: Remove const temporary that may prevent optimizationAlbert Astals Cid2020-04-231-2/+1
| | | | | | | | | | | | | | | | clang-tidy 10 was complaining about http://clang.llvm.org/extra/clang-tidy/checks/performance-no-automatic-move.html Change-Id: Iea5276e401a10f3ead8599e135dec1f0fa63a0dc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Convert QString to use QArrayDataPointerLars Knoll2019-12-161-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Final removal of the size and offset members from QArrayDataThiago Macieira2019-12-081-1/+1
| | | | | | | | | | | | | | | | Those members are not required anymore and now part of the object itself. Change-Id: If9eb5355ca8f2cf9528f6f63ca4e172acc9f9aed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Inline the size and data pointer members in QStringThiago Macieira2019-12-081-31/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'd have preferred to use QArrayDataPointer<ushort> for QString, but that option wasn't the best one. QArrayDataPointer try to do some operations using QArrayDataOps and that would expand to unnecessary code. What's more, the existing code expected to be able to modify and access the d pointer. Instead, this commit introduces QStringPrivate (named differently from QStringData to catch potential users), which contains the three members. This POD class is also used in QJsonValue to store the "inlined" QString. QHashedString in qtdeclarative will need a similar solution. Change-Id: I33f072158e6e2cd031d4d2ffc81f4a8dbaf4e616 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Stop using the reference counter to store data stateThiago Macieira2019-12-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | Instead of using the reference count to store whether the data is sharable and whether the header is immutable, move the settings to the flags member. This allows us to save one comparison per deref() or needsDetach(). It also allows for the possibility of mutable data pointed to by a static header. Change-Id: Ie678a2ff2bb9bce73497cb6138b431c465b0f3bb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Add reference-count manipulation functions to QArrayData and hide refThiago Macieira2019-12-081-1/+1
| | | | | | | | | | | | | | | | The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Introduce flags to indicate the QArrayData typeThiago Macieira2019-12-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These flags allow us to determine what type of data QArrayData is carrying. There are currently only two supported types: - raw data type: constructed via fromRawData or static data - allocated data type: regular data done via heap allocation The QArrayData object is usually allocated on the heap, unless its own reference count is -1 (indicating static const QArrayData). Such object should have a type of RawDataType, since we can't call free(). Add GrowsBackward for completeness as well as the StaticDataFlags default for static data. Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Replace QArrayData::capacityReserved with a full flags fieldThiago Macieira2019-12-071-1/+1
|/ | | | | | | | | | | | | Instead of stealing one bit from the alloc field, let's use a full 32-bit for the flags. The first flag to be in the field is the CapacityReserved (even though the allocate() function will store some others there, not relevant for now). This is done in preparation for the need for more flags necessary anyway. Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Deprecate QStringViewLiteralMarc Mutz2019-08-101-5/+2
| | | | | | | | | | | | | | | | | As a macro, we can't directly deprecate it, but need to make it call something deprecated. That is a new ctor with a new enum type added. The type might be useful for other such ventures, so put it into qglobal.h Remove the QT_NO_UNICODE_LITERAL protection, as it's always false these days, and QT_UNICODE_LITERAL is unconditionally #defined a 20 lines above. [ChangeLog][QtCore][QStringView] Deprecated the (undocumented) QStringViewLiteral macro. Just use u"" or QStringView(u"") instead. Change-Id: I9141320225037e1bc6b7f920bf01a9d0144fdac2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+112
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>