summaryrefslogtreecommitdiff
path: root/src/corelib/text/qstring.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into ↵v5.15.9-lts-lgpl5.15Tarja Sundqvist2023-03-231-1/+1
|\ | | | | | | | | | | tqtc/lts-5.15-opensource Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
| * QString: fix UB (pointer arithmetic on nullptr) in qLastIndexOfMarc Mutz2021-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Says ubsan: qstring.cpp:10484:17: runtime error: applying non-zero offset 18446744073709551614 to null pointer If we search for a null needle, we stored 0-1 in a size_t variable and unconditionally appied that offset to the needle's data() pointer. That being the nullptr, ubsan complained. To fix, set sl_minus_1 to 0 if it would underflow. In that case, sl_minus_1, n, and h, are not used, anyway, so their values don't matter as long as we don't invoke UB. Change-Id: Idca4e845c77838dfc84acdb68bbbc98382b5e1d5 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6830bdc1401e55680859b74036e9e9d90c359028) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/tqtc/lts-5.15.6' into ↵Tarja Sundqvist2022-08-161-7/+11
|\ \ | |/ | | | | | | | | tqtc/lts-5.15-opensource Change-Id: Ia9164a17d80376f0a3ab9752c4a9f4dd2f0bd3d9
| * Revert "QString::lastIndexOf: fix off-by-one for zero length matches"Tarja Sundqvist2021-08-181-2/+2
| | | | | | | | | | | | | | | | | | | | This reverts commit 3a273ac47f20e82a1f2f63411b210025ca0f4495. The revert is needed as QString::lastIndexOf was broken after the original patch. Task-number: QTBUG-94215 Change-Id: Ic1c81daa7b5ce8861911210ff34049ed7704ed4a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * Doc: Use https for links to unicode.orgPaul Wicking2021-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | * Change all outbound links in user-facing documentation. * Reflow lines that exceed 100 cols as mandated by clang-format. * Add unicode.org as a global \externalsite. Change-Id: I2ba1e434aa913e678406d62c2801f1a8b2d9e4f4 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> (cherry picked from commit 7968281444c967628566337ce3493058825cb946) Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
| * QString: Respect precision when reading data for %.*s format stringUlf Hermann2021-06-231-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | If we disregard the precision we may read a very large string that we subsequently discard. Furthermore, people use this to read non-null-terminated strings, which randomly crashes. Change-Id: Ifa255dbe71c82d3d4fb46adfef7a9dc74bd40cee Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit e99e07cb5c939ca5bbb1dfdeb66c862d6cd4f2f2) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/tqtc/lts-5.15.4' into ↵Tarja Sundqvist2022-04-071-0/+17
|\ \ | |/ | | | | | | | | tqtc/lts-5.15-opensource Change-Id: I3d223d54a832c8365fec4b399550da79f4c1abbb
| * Doc: Improve deprecation messages for functions using QString::SplitBehaviorKai Köhne2021-04-131-0/+13
| | | | | | | | | | | | | | | | | | | | | | Directly link to the recommended replacement. Inspired by forum.qt.io discussion: https://forum.qt.io/topic/125277/multiple-warning-messages-when-using-split-in-qt-5-15-2 Change-Id: Id880e892b90b6e37bc4f7888968a490b634785ce Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * QString: improve lastIndexOf(QRegularExpression) docsGiuseppe D'Angelo2021-04-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Due to how regex matching works, lastIndexOf has to be implemented by matching from the string's beginning until the from position is reached. This might not be obvious for users, so document that. Task-number: QTBUG-89050 Change-Id: I4b69ea753e7d417d980031926f1e01d77e58720d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 6f2dc8d7f27419d13bfbb2af272af99c03c66562) Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Revert "Update commercial license headers to src/concurrent and src/corelib"Tarja Sundqvist2021-03-231-20/+20
|/ | | | | | | | | | | This reverts commit b98b16de25dd5463342a2165a20b5fdc1cf9c32a. Revert of commercial license headers is required for Qt 5.15.3 opensource release. Task-number: QTBUG-91108 Change-Id: I51f2e169ec144ab9b902df2cff87eae60df53c57 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* Update commercial license headers to src/concurrent and src/corelibTarja Sundqvist2021-01-281-20/+20
| | | | | | | | | | | | | | | | | | | Updated the header.COMM to the files under tqtc-qtbase/src/concurrent and tqtc-qtbase/src/corelib. Note! The following files are not updated: - the .qdoc files with the FDL license headers - the .cpp files with BSD license headers The commercial license header may contain some additional lines so that its line count equals with the earlier license header. Reason for this is that some autotests use hard coded line numbers and changing the line count would cause test failures. Task-number: QTQAINFRA-4154 Change-Id: I37a4dc8c89b0a84d78ca890a61e212966d8b20b5 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QString::lastIndexOf: fix off-by-one for zero length matchesGiuseppe D'Angelo2020-12-101-2/+2
| | | | | | | | | | | Otherwise, it would report that lastIndexOf of an empty pattern in an empty string doesn't exist. Next commit adds extensive autotests; for now, disable a broken autotest (which already features a comment about why it's broken). Change-Id: I9a0e5c0142007f81f5cf93e356c8bd82f00066f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit be83ff65c424cff1036e7da19d6175826d9f7ed9)
* QString: fix count(QRegularExpression)Giuseppe D'Angelo2020-12-101-3/+9
| | | | | | | | | | | | | | | | | There is an off by one in the implementation of count(): a match must be attempted even at the very end of the string, because a 0-length match can happen there. While at it, improve the documentation on the counter-intuitive behavior of count(), which doesn't merely count how many times a regexp matches into a string using ordinary global matching. [ChangeLog][QtCore][QString] Fixed a corner case when using QString::count(QRegularExpression), causing an empty in the last position not to be accounted for in the returned result. Change-Id: I064497839a96979abfbac2d0a96546ce160bbc46 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 7c3208c97d2ad2c046908e144325c4ddb1e54876)
* Doc: Improve *_CAST_FROM_ASCII documentationKai Koehne2020-12-041-14/+9
| | | | | | Change-Id: Iba73c0a38e2c4add740aab20036aa39c56eb4d98 Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit 50873153a70521e138b590a227902876f998270e)
* Doc: Consistently use book style capitalization for QStringKai Koehne2020-11-301-1/+1
| | | | | | Change-Id: I2ab64fe58ad737b23f0829ed91591efaa0c22c6f Reviewed-by: Paul Wicking <paul.wicking@qt.io> (cherry picked from commit efa05e04176067a2e5b4d133943d854c9c08bbe7)
* Fix logic error in QString::replace(ch, after, cs)Andreas Buhr2020-11-201-1/+1
| | | | | | | | | | | Coverage analysis showed that an if-branch marked "Q_LIKELY" was never taken. It turns out the code was incorrect, but behaved correctly. This patch fixes the logic and adds a unit test. Change-Id: I9b4ba76392b52f07b8e21188496e23f98dba95a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ebaae45ea17efc230209ed90d94596647cf6cb48) Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Add some missing QStringView overloads to QStringLars Knoll2020-10-151-0/+84
| | | | | | | | | | | | | | | | | | | These are added to aid writing portable code between Qt 5.15 and Qt 6. [ChangeLog][QtCore][QStringView] A couple of methods have been added to QStringView that make it easier to write code that is portable between Qt 5.15 and Qt 6. Those include QStringView::split(), QStringView::count(), number conversion methods (QStringView::toInt() and friends). A couple of overloads taking QStringView have been added to QRegularExpression (match() and globalMatch()) and QString (append(), prepend(), insert() and localeAwareCompare()). Fixes: QTBUG-86516 Change-Id: I98779217c7a4107fbe086f956d24b1ce059194d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Reference proper SplitBehaviour enum in docsNicolas Fella2020-10-021-1/+1
| | | | | | | | | | QString::SkipEmptyParts is Qt::SkipEmptyParts now. Change-Id: Ie351bbe9d2350e771f821a9f0bc9f581be5b0022 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kai Koehne <kai.koehne@qt.io> (cherry picked from commit 2d8d8ab8c2a1386878429f57f6069d2f86f7708b) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtPrivate::isLatin1: fix SSE2 non-SSE4.1 codeThiago Macieira2020-08-061-20/+1
| | | | | | | | | | | | | | The implementation was broken. The "high" in PUNPCKHBW's "unpack high data" means the high 64-bit of the 128-bit, not the high byte of a 16- bit word. This never worked. It always passed for me because I don't build non-SSE4.2 code (too old, no longer relevant). So just use the working version of simdTestMask. Change-Id: I35a1b4d0a19a43149daefffd16284542f0de3fa3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 9422b5ebc3592f4687650a84131e736219308b9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qustrlen: Add #warnings to explain how to deal with GCC 7.x's ASanThiago Macieira2020-08-061-0/+7
| | | | | | | | | | | | | | | | The build breaks by disabling ASan in this function because it also removes its ability to emit SSE2 code. That's clearly broken because all x86_64 can use SSE2. So this adds #warnings so people are told how to choose their solution. Clang doesn't currently define __SANITIZE_ADDRESS__ but I added a conditional just in case some future version does. Fixes: QTBUG-84856 Change-Id: I552d244076a447ab92d7fffd1617875fdd8dbe62 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 3caeb0187dec592c78a3bde8d0284475e00e30d4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Be clearer about the locale-aware comparison QString supportsEdward Welbourne2020-07-301-95/+61
| | | | | | | | | | | | | | | | | The docs didn't make clear that there's a case where a rather poor locale-aware compare may be in use - which turns out to be in use on Android. In the process, stop duplicating (in two slightly different variants) the same paragraph in many places when we can use a \sa to refer to a sub-section of the class doc. Task-number: QTBUG-63518 Change-Id: I5a41b0a269e477e74236131310992e70462734d7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Topi Reiniö <topi.reinio@qt.io> (cherry picked from commit 2ab4fe2ac84d0da84b489f9898d44ab77b78fd6b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* QString: fix an aliasing issue in remove(QString)Marc Mutz2020-05-211-1/+9
| | | | | | | | | | | | Even in Qt 5, remove() can be passed an alias to *this. In Qt 6, with the advent of substring sharing, this will become even more pronounced. Use the same fix as was already used in QString::insert(). Change-Id: I1a0d3d99fd7dff6e727661646d2cbfdc94df2682 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit b655734965155146290f3f3a9205243af11e42fb) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString: optimize insert() of a substringMarc Mutz2020-05-211-5/+2
| | | | | | | | | | The old code malloc()ed a buffer to hold a copy of the data if a substring of *this was to be inserted. Instead, use a QVarLengthArray. Change-Id: Ia3b4d7509bff2375ec0da5c890ecff2e9f7f335c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 2ed048fa8dd506a8e57292e49dadd37011354a83) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: fix UB in replace()Marc Mutz2020-05-211-1/+2
| | | | | | | | | | | | | | | | Comparing with <, >, <= or >= such pointers as are not pointing into the same array is UB. A clever compiler could look at the code, determine that the only valid execution is for it to return true, and just always take the copy. While that would be benign, it's not guaranteed that this would be the outcome (it's UB, after all), and, of course, we don't want to take the performance hit if we don't need it. Change-Id: I48cda232ff10a3c9fd4babcd7e7103a3aed126e8 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit f6b96bc34749e4478e75c081bbd0af406cd737b5) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString: fix quadratic behavior in QString::remove(QString)Marc Mutz2020-05-211-10/+24
| | | | | | | | | | | | | | | | | Calling linear-complexity remove(int, int) in a loop is O(N²). Fix by implementing a remove_if()-like algorithm which ensures each character is written at most once, which is linear. [ChangeLog][QtCore][QString] Fixed quadratic worst-case complexity of remove(QString). The function now has linear complexity in all cases. Change-Id: I12f70fbc83fb5da4a9aae4bd02f525d7657cc940 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 49e69827d2be045751ded48645904b4349115212) Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString: mark qustrlen() as unsuitable for ASanThiago Macieira2020-05-201-0/+5
| | | | | | | | | | We load an aligned 16-byte on the first load, even if 14 of the 16 bytes are before the string contents themselves. Change-Id: Ibdc95e9af7bd456a94ecfffd1603f2b8c87655b1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> (cherry picked from commit 3144f90d93c2b6209e3b8a65bb9655cc7c6ada79) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QString: fix premature pessimisation in arg(char-ish)Marc Mutz2020-05-191-6/+2
| | | | | | | | | | Instead of converting the char or QChar to a QString, convert them to a QStringView, saving the memory allocation. Change-Id: I023712ec00172f1c8570e762817bfc3a95e01125 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from commit e201d585401ea4affe8dde3f4f43f15bf49fa229) Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QString: fix UB in insert()Marc Mutz2020-05-191-1/+2
| | | | | | | | | | | | | | | | | | | Comparing with <, >, <= or >= such pointers as are not pointing into the same array is UB. A clever compiler could look at the code, determine that the only valid execution is for it to return true, and just always take the copy. While that would be benign, it's not guaranteed that this would be the outcome (it's UB, after all), and, of course, we don't want to take the performance hit if we don't need it. Fix by using std::less, which guarantees a total ordering for all pointers. Change-Id: If07b9363b2ecd573f259e4fa972b629362061ce5 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit c3b5efa250ee29413d348fea96e11b7e6f94e54f) Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Remove manual duplicate alias descriptionsPaul Wicking2020-04-281-32/+0
| | | | | | | | | | With the introduction of the \typealias command to QDoc, QDoc generates a standardized line for aliased types. This patch removes duplication caused by the change in QDoc. Change-Id: I1a01c378f85b0decb7c0400a3b21146f0898c6ec Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QLatin1String/QStringView: add (missing) member compare()Marc Mutz2020-03-051-0/+17
| | | | | | | | | | | [ChangeLog][QtCore][QLatin1String] Added compare(). [ChangeLog][QtCore][QStringView] Added compare() overloads taking QLatin1String, QChar. Change-Id: Ie2aa400299cb63495e65ce29b2a32133066de826 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QByteArray: make all symmetry-checked member-compare() combinations ↵Marc Mutz2020-03-051-0/+23
| | | | | | | | | | | | | | | | | | | noexcept In QByteArray, they were just not marked as such. In QString and QStringRef, the implicit conversion from QChar to QString would destroy it. Add a QChar overload, delegating to QStringView. Added docs for the new overloads, copying from the nearest neighbor so as to not look out of place. All string classes use different wording for these functions. A cleanup of this state of affairs is out of the scope of this patch. Change-Id: I0b7b1d037aa229bcaf29b793841a18caf977d66b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Suppress warnings where QString and its tests use SplitBehaviorEdward Welbourne2020-03-031-0/+3
| | | | | | | | This is a follow-up to commit 895939c7f91d0c8424a0638c42d05cb42293a142 to fix deprecation warnings it added. Change-Id: I3d86655ec2c84c1bdcac9c70436075fc78f2f781 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate QString::SplitBehavior in favor of Qt::SplitBehaviorEdward Welbourne2020-02-281-1/+35
| | | | | | | | | This requires changing which of the two families of methods gets to take a default argument for its behavior. Task-number: QTBUG-81853 Change-Id: I6759bedd9af364d6e12bb39cd539b5dcba37027e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* De-inline Qt::SplitBehavior splitters of QString and QStringRefEdward Welbourne2020-02-281-25/+125
| | | | | | | | | | | Convert the QString::SplitBehavior variants to call them, rather than the other way round and convert the internal infrastructure to use Qt::SplitBehavior, ready to deprecate the QString::SplitBehavior versions without generating intenal warnings. Task-number: QTBUG-81853 Change-Id: Ia6b78881c3d0e30a7bbd4dfd00cc15a407f448a2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-221-0/+6
|\ | | | | | | Change-Id: Iace12004afdfe765a3068dfcf6f1320c1123c539
| * QString: Add missing number() crosslinks to setNum()Andre Hartmann2020-02-201-0/+6
| | | | | | | | | | | | Change-Id: I22a4c86034b399782115bb078c298b211095476a Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-01-131-18/+26
|\ \ | |/ | | | | Change-Id: I50f70a789ab1438b40d4408be72c090fa00b801f
| * QString::isLower/isUpper: redo the implementationGiuseppe D'Angelo2020-01-111-18/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use QStringIterator rather than indexed loops. This fixes handling of non-BMP code points (which may be lower or uppercase, see the test). Change also the semantics of the functions, adopting Unicode §3.13 definitions: a string is lowercase/uppercase if it's equal to its own toLower/toUpper folding. As a side effect, empty strings are now correctly reported to be lowercase AND uppercase. [ChangeLog][Important Behavior Changes] The semantics of QString::isLower() and QString::isUpper() have been changed to match the Unicode specification. Now lowercase (resp. uppercase) strings are allowed to contain any character; a string is considered lowercase (resp. uppercase) if it's equal to its own toLower() (resp. toUpper()) folding. Previously, a non-letter character would make the string not lowercase nor uppercase, and the mere presence of an uppercase (resp. lowercase) letter would make isLower() (resp. isUpper()) return false, even if the letter wouldn't change under case folding. As a consequence, now empty strings are lowercase and uppercase. [ChangeLog][QtCore][QString] Fixed a number of bugs of QString::isLower() and QString::isUpper(). Empty strings are now correctly reported to be lowercase (resp. uppercase), and strings containing code points outside the BMP are now correctly handled. Note that the behavior of these functions has also been changed. Change-Id: Iba1398279a072399a9f21295fe75f6e414f3f813 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.14' into 5.15Liang Qi2020-01-091-4/+4
|\ \ | |/ | | | | | | | | | | Conflicts: src/corelib/kernel/qobject.cpp Change-Id: I4780b25665672692b086ee92092e506c814642f2
| * ucstrncmp: Fix UBSan report of array overflowingThiago Macieira2020-01-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The expression "a + offset + N" will eventually calculate an address past the end of a, since we are comparing to end. That's undefined behavior. Instead, calculate end - a and compare that to offset + N. This commit subtracts "a" from both sides of the inequalities and swaps the two sides to make them obey Qt coding style. Testing with GCC 9 (which is the only one I care about) shows the compiler generates the same code. Fixes: QTBUG-81218 Change-Id: Id84da383373844f3a4b0fffd15e7c1ab904daccd Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Introduce QString(View)::isValidUtf16Giuseppe D'Angelo2019-12-201-0/+29
|/ | | | | | | | | | | | | | | | | | | QString(View)s can be built or manipulated in ways that make them contain/refer to improperly encoded UTF-16 data. Problem is, we don't have public APIs to check whether a string contains valid UTF-16. This knowledge is precious if the string is to be fed in algorithms, regular expressions, etc. that expect validated input (e.g. QRegularExpression can be faster if it can assume valid UTF-16, otherwise it has to employ extra checks). Add a function that does the validation. [ChangeLog][QtCore][QStringView] Added QStringView::isValidUtf16. [ChangeLog][QtCore][QString] Added QString::isValidUtf16. Change-Id: Idd699183f6ec08013046c76c6a5a7c524b6c6fbc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize qLastIndexOf<QString> to not detach the QStringDavid Faure2019-12-051-2/+5
| | | | | | | | | | | | | | | | The call to data() on a non-const QString led to a detach(), which is unexpected and unwanted from QString::lastIndexOf() const. Found by looking at why QFileSystemEntry::fileName() was expensive, in the hotspot profiler. The solution is to instanciate QLastIndexOf with QStringView() rather than QString(). I added a deleted QString overload to make sure nobody ever instanciates it with a QString argument again. Change-Id: I06a1b2f937425e83f0779eb215e099aef78c50a7 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUnicodeTables: use array for case folding tablesMarc Mutz2019-09-041-15/+15
| | | | | | | | | | | | | | | | | Instead of four pairs of :1 :15 bit fields, use an array of four :1, :15 structs. This allows to replace the case folding traits classes with a simple enum that indexes into said array. I don't know what the WASM #ifdef'ed code is supposed to effect (a :0 bit-field is only useful to separate adjacent bit-field into separate memory locations for multi-threading), but I thought it safer to leave it in, and that means the array must be a 64-bit block of its own, so I had to move two fields around. Saves ~4.5KiB in text size on optimized GCC 10 LTO Linux AMD64 builds. Change-Id: Ib52cd7706342d5227b50b57545d073829c45da9a Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-041-2/+2
| | | | | | | | | | | Conflicts: src/corelib/codecs/qicucodec.cpp src/dbus/qdbusserver.cpp src/gui/painting/qbezier.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/printsupport/cups/qppdprintdevice.cpp Change-Id: I2703128bb64baf5580fbc2c2061b55b0f0611d2a
* qstringalgorithms.h: add pure, noexcept, constexprMarc Mutz2019-07-291-1/+1
| | | | | | | ... where they were missing. Change-Id: I58c32e57675b5d5ee500722933ef4a356a679e46 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-121-2/+2
| | | | Change-Id: Icaabf08f9af539ddf844d96bc9c3a2d09408ba8a
* Move text-related code out of corelib/tools/ to corelib/text/Edward Welbourne2019-07-101-0/+12592
This includes byte array, string, char, unicode, locale, collation and regular expressions. Change-Id: I8b125fa52c8c513eb57a0f1298b91910e5a0d786 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>