summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringalgorithms.h
Commit message (Collapse)AuthorAgeFilesLines
* QUrl: Add qustrchr() and use it to speed up the fast URL full decodingThiago Macieira2018-08-031-0/+1
| | | | | | | | | | | | | The character search in the findChar() static function in qstring.cpp is more efficient than what we had in qurlrecode.cpp and there's no point in duplicating it. It also has a Neon implementation. So make the implementation available for use in QtPrivate::qustrchr(). This also simplifies the implementation. Change-Id: Ib48364abee9f464c96c6fffd152eedd0cd8ad7f8 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a few methods to check if a string is US-ASCII or Latin1Thiago Macieira2018-01-271-0/+5
| | | | | | | | | isLatin1(QLatin1String) is provided for completeness sake, in case some generic code operates on both QLatin1String and QString/QStringView. Change-Id: I5e421e32396d44e4b39efffd150b99a18eedf648 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Update QString::isRightToLeft() to take directional hints into accountLars Knoll2018-01-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Make sure we properly handle both directional embeddings as well as directional isolates to determine the direction of the string. According to the latest version of the Unicode bidi algorithm, parts of the string contained inside an directional isolate is to be ignored when determining the paragraph direction. Embedding markers themselves are to be ignored as well, but not the characters inside an explicit directional embedding or override. This is also some required pre-work to get our BiDi algorithm updated to the latest version of the standard. Move the implementation to QStringView and implement the methods in QString and QStringRef through that implementation. Task-number: QTBUG-57743 Change-Id: I7f24e09198e22d6359c6534c9ae40a904e94c46e Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Improve readability of code that uses the Qt signed size typev5.10.0-rc2Simon Hausmann2017-11-281-1/+1
| | | | | | | | | | | | | | | | | During the container BoF session at the Qt Contributor Summit 2017 the name of the signed size type became a subject of discussion in the context of readability of code using this type and the intention of using it for all length, size and count properties throughout the entire framework in future versions of Qt. This change proposes qsizetype as new name for qssize_t to emphasize the readability of code over POSIX compatibility, the former being potentially more relevant than the latter to the majority of users of Qt. Change-Id: Idb99cb4a8782703c054fa463a9e5af23a918e7f3 Reviewed-by: Samuel Gaist <samuel.gaist@edeltech.ch> Reviewed-by: David Faure <david.faure@kdab.com>
* Mark the previously public qstringalgorithms.h functions privateThiago Macieira2017-10-291-18/+22
| | | | | | | | | | | | | | | | | | | | | Discussed during Qt Contributor Summit 2017. We concluded that we don't want to make these functions public, as they do not follow Qt coding style API. Specifically, qStartsWith(a, b) is not easily understood which argument is the needle and which argument is the haystack (same problem memcpy() has). Compare that to a.startsWith(b) which can clearly be read in English as a subject-verb-object sentence. This commit removes the unit tests that called compare(). Discussed-on: http://lists.qt-project.org/pipermail/development/2017-October/031060.html Change-Id: Icaa86fc7b54d4b368c0efffd14ee6205eb9043fb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QStringView: De-inline the length calculation so we can use SSE2Thiago Macieira2017-09-131-0/+2
| | | | | | | | | | | | | | | | | | Performance is more important in this case than the theoretical benefit of constexpr. This commit implements the SSE2 search for 16-bit null and it might be possible to implement the equivalent for AArch64 (investigation required). It also adds a fallback to wcslen() for systems where wchar_t is short (non-x86 Windows or 32-bit x86 build with -no-sse2). We can re-add the constexpr loop once the C++ language has a way of overloading constexpr and non-constexpr. GCC has a non-standard way to do that with __builtin_constant_p, which is also implemented in this commit, but note that the inline function is still not constexpr. Change-Id: I6e9274c1e7444ad48c81fffd14dcaacafda5ebdc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStringView/QLatin1String: add trimmed()Marc Mutz2017-05-161-0/+2
| | | | | | | | | | | | | | | | | | | ... using the same qt_trimmed(), qTrimmed(), Q..::trimmed() split we've been using for all other out-of-line string-view member functions to avoid forcing string-view objects onto the stack for the passing of 'this'. In the test, had to fix nullness not being propagated from a QByteArray to the QLatin1String constructed from it. Probably worth fixing in QLatin1String(QByteArray), too. [ChangeLog][QtCore] Added qTrimmed() free functions. [ChangeLog][QtCore][QLatin1String] Added trimmed() function. Change-Id: I73c18ef87e203f30f7552c10dd5c84223bcfae0e Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move Q_REQUIRED_RESULT to first in line in qstringalgorithms.hMarc Mutz2017-05-161-8/+8
| | | | | | | | Necessary to support C++17's [[nodiscard]] attribute, which needs to be placed at the beginning of a function declaration. Change-Id: I31494d13c7be558e86378782ab8684ef2956730b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live qStartsWith()/qEndsWith()!Marc Mutz2017-04-281-0/+12
| | | | | | | | | | | | | | | | | Following the established pattern of implementing non-mutating string algorithms as free functions over views with a public qFoo() and a static qt_foo() split, add qStartsWith() and qEndsWith(), calling the existing qt_{starts,ends}_with_impl() templates. [ChangeLog][QtCore][QStringAlgorithms] Added qStartsWith(), qEndsWith(). Change-Id: Ic95c2a9c13883a99f1a96319083fb249f20de5f1 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disentangle string-related headersMarc Mutz2017-04-251-0/+68
It's starting to hinder QStringView development (QString::append(QStringView), e.g.). - qbytearray.h includes qstring.h, but is included by qstring.h -> remove qstring.h include from qbytearray.h - the QStringLiteral definition is used from both qstring.h and qstringview.h -> extract into its own header, move QStringViewLiteral definition there, too - the qCompareStrings(), qConvertTo*() functions are used by QString and QStringView -> also extract into own header, included from qstring.h and qstringview.h - QStringView::toString() depends on QString, which depends on QStringView -> move QStringView::toString() definition to qstring.h, after the definition of QString -> move qstringview.h up to all the other includes in qstring.h This is starting to look like a DAG again, and allows to remove the unholy #ifndef QSTRING_H # include <qstring.h> #endif hack from qstringview.h. [ChangeLog][Potentially Source-Incompatible Changes][QByteArray] qbytearray.h no longer includes qstring.h. In particular, this means that in order to use QStringBuilder with QByteArray, you need to include both qbytearray.h and qstring.h now (or <QByteArray> and <QString>, resp.). Change-Id: I7f8acf9c11bc1731266cd25c6eda9fb36723f364 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>