Commit Graph

1117 Commits (c630b231ecd674b80a554bf40b37086b64c73f6a)

Author SHA1 Message Date
Ahmad Samir c630b231ec Untangle QLatin1StringView from qstring.{h,cpp}
Searching in qstring.{h,cpp} is slightly easier (it's already too
long).

From the task:
Having similarly-structured header files for all the view classes would
help rebasing the different view classes onto a common template come Qt
7.

Diff best viewed in terminal with git's diff.colorMoved config set to
default.

Task-number: QTBUG-103509
Change-Id: Ie791760bb5bfa23def98d67c206ae8fd00c5f6e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-07 04:03:22 +02:00
Ahmad Samir a608744c90 Docs: adjust docs after the QLatin1String to QLatin1StringView rename
Unify wording as "{Latin-1,UTF-16} string viewed by \a str".

Drive-by change: Fix a grammatical error, it's "a US-ASCII", not an
(because it's pronounced by the letter name "U" which is pronounced
like "you", so "a" not "an").

Task-number: QTBUG-108711
Pick-to: 6.5
Change-Id: Iff763f4008341c35317bb3d7a2a228767ff6a648
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-01-05 14:46:38 +02:00
Ahmad Samir 9aaf258211 QStringBuilder: document issues with using "auto" keyword
Cleanup QStringBuilder API docs.

Task-number: QTBUG-104354
Change-Id: I00029c8f4bfdf35869396ac14d7d9ba0da34cdb5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-01 17:47:04 +02:00
Ahmad Samir 5d76c49e9c Use more documentation snippets for QString and its siblings
Pick-to: 6.5
Change-Id: Ia569806b586923473f68b9fe1d98a3628ba46a58
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-01-01 14:13:50 +02:00
Ahmad Samir bab660d124 QStringConverter: add QLatin1::convert{To,From}Unicode()
With the methods that use helpers from qstring.cpp defined in the
latter.

Change-Id: I11d6b0bfb95efe34e56d33d2ecbfe8f4423a9e6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-30 16:36:24 +02:00
Ahmad Samir ad32854409 Add QUtf8::convertToUnicode(char16_t *, ....) overloads
Mark private API docs as \internal.

Change-Id: Ia2fae84832d5f253ea730c1993ce1810f43dff78
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-23 19:22:30 +02:00
Øystein Heskestad f46bcad993 Remove superfluous Latin-1 case folding table
Use new case folding functions in the implementation of
QLatin1StringMatcher instead.

Task-number: QTBUG-100236
Change-Id: I853091d11070483ad2128b9de3c776f5ca8e7f45
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-22 20:02:29 +01:00
Ahmad Samir 8f0c366087 QStringConverter: don't shadow variables
Change-Id: I3c209585de2a7599f1cd4e58c1d3b3501425b903
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-20 15:16:31 +02:00
Marc Mutz 451dbca16c QString: use new QUtf8StringView overloads
... to prepend/append/insert QByteArray and const char*, instead of
the old inline QString::fromUtf8(), which litters the call sites with
temporary QString objects.

Can't use qToUtf8StringViewIgnoringNull() for QByteArray parameters to
avoid the extra isNull() check, because some QString tests depend on
whether we append/prepend/insert null or empty.

Pick-to: 6.5
Fixes: QTBUG-109092
Change-Id: Ibf7b99aad844d0c2219ccc1c30f6666c5dfc7758
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-19 19:05:46 +01:00
Marc Mutz ba52b29d33 QLatin1/String/View: don't decay the arg() arguments
This turns const char[] arrays into const char* pointers and
therefore prevents the implicit conversion of string literals
to QString in QT_RESTRICTED_CAST_FROM_ASCII.

Fix by avoiding the decay.

Also simplify the template magic.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I88164a1866ac71b41d9cd1564f3a5e83d2d42aaa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-17 07:18:07 +00:00
Ahmad Samir e3ae2a505e QString: add needsReallocate() static helper
Split it out from resize(), will be reused in do_replace_helper().

Change-Id: If779e03196678e1618f0ecc114448fed796b43d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-13 14:41:29 +02:00
Ahmad Samir 6f2a1430c9 QString: don't use noexcept if the method could allocate memory
Change-Id: I49dbd25a41152995d0843fa54d7b3cb4045f3849
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-13 14:41:29 +02:00
Ahmad Samir 2fe3b0e564 QContainerTools: add q_points_into_range overload
Looking at the use-cases of the already existing q_points_into_range
overload, all of them can be ported to the new one (i.e. all of them
were using range [begin, end)).

Change-Id: I4bfdd68271512b88a9800a16237ff967a367eaeb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-11 15:44:26 +02:00
Ahmad Samir 59fb33e095 QString: add convenience method converting latin-1 into a QVLA
Less code duplication, as "convert Latin-1 data to Utf16 and store in a
QVLA" is used in various places.

Change-Id: I861f5b8f988411d400db0440b0f5a56c5365e990
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-10 23:37:20 +02:00
Marc Mutz 50a0c4f3ce QString: fix append/prepend/insert/op+= with QT_RESTRICTED_CAST_FROM_ASCII
Since adding the QUtf8StringView overloads, calling these overload
sets with const char string literals became ambiguous in
QT_RESTRICTED_CAST_FROM_ASCII builds (both QString and QUtf8StringView
are a match).

Fix by providing the same templated overloads that
QT_RESTRICTED_CAST_FROM_ASCII enables for QString construction and
assignment for append/prepend/insert/op+=, too.

Incidentally, this makes these operations much faster than when they
constructed a temporary QString.

Change-Id: Ie9b38fc80cc00e142e094dab716938c6fda41ba1
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-09 07:22:13 +01:00
Marc Mutz 41a994db06 QAnyStringView: add substringing operations
Add the full set of substringing operations:
- mid/left/right (old-style)
- sliced/first/last (new style)
- chop/chopped/truncate

The implementation is copied from QUtf8StringView, adjusted to use
sliced() instead of the (ptr, n) ctor, so we need to deal with the tag
twiddling only once, in sliced().

The documentation is also copied from QUtf8StringView.

[ChangeLog][QtCore][QAnyStringView] Added substring functions
sliced(), first(), last(), chop()/chopped(), truncate().

Change-Id: Ief454e9694519e97d9146fa84bc05dda1dded046
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-08 18:00:16 +00:00
Øystein Heskestad 3fedcd4e4a Add Boyer-Moore Latin-1 string searcher with optional case sensitivity
[ChangeLog][QtCore][QString] Added Boyer-Moore Latin-1 string searcher with optional case sensitivity

Task-number: QTBUG-100236
Change-Id: I200a0dac7c8012add1ee02511dba791d233115e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-08 17:56:47 +01:00
Kai Köhne cbd5bc0b58 Doc: Fix paths for Files property in qt_attribution.json files
qtattributionsscanner expects file paths to be separated by a space.

Pick-to: 6.2 6.4
Change-Id: I4c9dfea0f086fc9631cb06f40e2d3cab0a32ca4e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-12-08 15:14:17 +01:00
Thiago Macieira 3465b9fe74 QString: merge and optimize the two overloads of SSE2's ustrncmp()
The algorithm is the same, differing only on how we load data onto
vector registers, so they can be merged, simplifying the code base.

For all strings over 16 characters in length, we loop and then we
perform a final overlapped comparison, if necessary. I've kept the 32-
byte-per-loop solution even for pre-AVX2, because that should pipeline
better. For any strings between 4 and 16 characters, we perform a pair
of maybe-overlapped comparisons, of either 4 characters or of 8, so we
consume the full string. That leaves a tail of at most 3 characters in
scalar code.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c8c15d6d761af2
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-07 09:57:59 -08:00
Axel Spoerl 2f22a6e465 Mark static mm_load8_zero_extend [[maybe_unused]]
static Q_ALWAYS_INLINE __m128i mm_load8_zero_extend(const void *ptr)
is unused when compiled on Android.
This causes a compiler warning and blocks CI, if compiled with -Werror.

This patch marks the method [[maybe_unused]], in order to prevent the
warning.

Change-Id: Ife10c0a84ac34196405ce9c2356351d825751adb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-07 10:26:06 +01:00
Marc Mutz 6631444eb1 QString/QByteArray/QList: de-pessimize op+ [2/2]: overload on rvalue LHS
The + operator is left-associative, so a + b + c is (a + b) + c.

Apply the same trick C++20 applied to std::string's op+ and overload
for rvalue left-hand sides. This means that a + b + c is now
equivalent to

  [&] {
      auto tmp = a;
      tmp += b;
      tmp += c;
      return tmp;
  }()

removing a ton of temporary buffers (not objects, because CoW makes it
impossible for the compiler to track the single conceptual object
passing through the chain) when not using QStringBuilder (which isn't
available for QList).

This is BC, because the operators are all inline free functions or at
least inline members of non-exported classes.

Use multi-\fn to document the new operators. No \since is needed, as
this doesn't change the set of supported operations, just makes some
of them faster.

[ChangeLog][QtCore][QList/QString/QByteArray] Chained additions (a + b
+ c) now produce only one temporary buffer for the whole expression
instead of one per addition. Using += or QStringBuilder is still
faster, though.

Change-Id: I87e837d8803e79dc29c9268f73e6df9fcc0b09a3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-07 07:39:38 +00:00
Thiago Macieira e02933a17c QAnyStringView: move the two assertions to a central place
Move the assertions to qtypes.cpp, next to where one of them already
existed.

Change-Id: I51d12ccdc56c4ad2af07fffd172dae7c49d78273
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-07 06:24:14 +00:00
Thiago Macieira 8be744df8a QAnyStringView: move the tag bits to the LSB for Qt 7
This removes the TODO that was left in the file. It's also applied for
bootstrapped use of QAnyStringView, even though it's currently not used
in the bootstrap lib.

Along with the previous commit of inverting the order of the members,
the code generated by GCC 12 for a visitation compares as:

_Z1f14QAnyStringView:                                           _Z1f14QAnyStringView:
        movabsq $4611686018427387903, %rcx                    |         movq    %rsi, %rax
        movq    %rdi, %rdx                                    |         shrq    $2, %rsi
        movabsq $-4611686018427387904, %rax                   |         andl    $3, %eax
        andq    %rsi, %rax                                    |         cmpq    $2, %rax
        andq    %rcx, %rsi                                    <
        movabsq $-9223372036854775808, %rcx                   <
        cmpq    %rcx, %rax                                    <
        je      .L15                                                    je      .L15
        movabsq $4611686018427387904, %rcx                    |         cmpq    $1, %rax
        cmpq    %rcx, %rax                                    <
        je      .L16                                                    je      .L16
        jmp     _Z1fI20QBasicUtf8StringViewILb0EEEvT_                   jmp     _Z1fI20QBasicUtf8StringViewILb0EEEvT_
.L16:                                                           .L16:
        movq    %rsi, %rdi                                    |         jmp     _Z1fI17QLatin1StringViewEvT_
        movq    %rdx, %rsi                                    <
        jmp     _Z1fI13QLatin1StringEvT_                      <
.L15:                                                           .L15:
        movq    %rsi, %rdi                                    <
        movq    %rdx, %rsi                                    <
        jmp     _Z1fI11QStringViewEvT_                                  jmp     _Z1fI11QStringViewEvT_

Fixes: QTBUG-109086
Change-Id: I51d12ccdc56c4ad2af07fffd172db128ca4105a5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-06 22:24:14 -08:00
Thiago Macieira 497275a8ba Q{Latin1,}StringView: invert members so the order is (data,size) in Qt7
Matches Q{Any,Utf8}StringView as well as std::basic_string_view in
Microsoft's STL and LLVM libc++, but not GCC's libstdc++. Interestingly,
it does match the order in libstdc++'s non-small std::basic_string.

Applied for bootstrapped use, so we ensure this works and keeps working.

Change-Id: I51d12ccdc56c4ad2af07fffd172db18254fff083
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-06 22:24:14 -08:00
Morten Sørvig 01412ff16e wasm: add native QByteArray conversion functions
Add functions which converts to and from JavaScript
data arrays:

  static QByteArray::fromUint8Array(emscripten::val array)
  emscripten::val QByteArray::toUint8Array() const

with corresponding internal qstdweb API:

  static Uint8Array Uint8Array::copyFrom(const QByteArray &buffer)
  QByteArray Uint8Array::copyToQByteArray() const

Both functions will make a copy of the data, i.e. there
is no shared reference counting. They take and return
Uint8Array typed array views, via emscripten::val JavaScript
object references.

Unlike other native conversion functions, these have
the special property that the data referenced by the
native Uint8Array exists outside the heap memory area.

This means we can’t e.g. memcpy the data. However, the
heap is itself a JavaScript ArrayBuffer, and we can
create a Uint8Array view to the buffer owned by the
QByteArray, and then use JavaScript API to copy. See
the qstdweb::Uint8Array::copy() implementation.

That also means that a fromRawUint8Array() variant
(which does not copy) is not possible to implement,
since we can’t create a pointer to the source data.

The inverse toRawUint8Array() is implementable - it
would return a Uint8Array view which references the
heap’s ArrayBuffer. However, this may turn out to be
ill-advised, since Emscripten will create a new ArrayBuffer
if/when it resizes the heap. In any case this left for
a future expansion.

Change-Id: Icaf48fd17ea8686bf04cb523cc1eb581ce63ed34
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-12-05 13:04:51 +00:00
Thiago Macieira 33e682f9af QString: use memcmp() in ucstrncmp() where it's acceptable
ucstrncmp() exists because memcmp() can't be used to sort UTF-16 code
units in little-endian platforms. But it can be used in big endian
platforms and when sorting isn't necessary.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c908c46cc9af2d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-04 17:56:45 -08:00
Thiago Macieira 339aa99fec QString::toLatin1: do the same as fromLatin1 for sub-16 characters
Perform a pair of overlapped loads & stores, so we can perform the
contracting and inserting of question marks in vector code.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c2f5e479b0f6fa
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Thiago Macieira 3ef43ca837 QString::fromLatin1: improve the sub-16-character case
For both the [4, 7] and [8,15] length cases, we can perform the same
technique: perform two overlapped loads, zero-extend, then perform two
overlapped stores. The 8-character case could be done in a single
load/store pair, but is not worth the extra conditionals. And it should
have the exact same performance numbers whether we use non-overlapping
4-character operations or completely-overlapping 8-character ones (I
*think* the full overlap is actually better).

The 4-character operation is new in this commit. That reduces the
non-vectorized, unrolled to at most 3 characters.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c257ada774236a
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Thiago Macieira 2b9d4afc95 QString::{to,from}Latin1: add the ability to do overlapping tails
If the string length is larger than the number of characters we can
operate on with a single vector loop, we can transform the tail using a
vector too, just overlapping up to 15 characters with the last iteration
o the loop.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c2dcab115e50f7
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Thiago Macieira 3b528670e6 QString::toLatin1/SSE: simplify the code to merge question marks
Just move the test of Checked into the lambda, so we can call it
unconditionally.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c9b84ff4a31bb9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-04 17:56:45 -08:00
Thiago Macieira 23f1d68b09 QString: improve the SSE2 qustrlen to calculate the length as we go
Instead of updating the pointer that we're reading, update the offset
(which is the length). The number of variables we're operating on is the
same (2), but this simplifies the calculation at the end.

BEFORE                             | AFTER
        tzcntl  %edx, %edx         |         tzcntl  %edx, %eax
        subq    %rdi, %rax         |
        sarq    %rax               |
        shrl    %edx               |         shrq    %rax
        addq    %rdx, %rax         |         leaq    (%rax,%rcx), %rax
        ret                        |         ret

We remove one subtraction and one shift. I don't know why it decided to
use LEA instead of ADD... The shift changed from 32- to 64-bit because
we cleaned up the constant 2 (an int) in the file with sizeof(char16_t)
(a size_t), but that has no effect in performance.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c9650a60289f4c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Thiago Macieira 1acd028b0c QString: move the body of qustrlen's SSE2 implementation
Change-Id: I0e5f6bec596a4a78bd3bfffd16c96189533ad94e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-04 17:56:45 -08:00
Thiago Macieira 40083f380f QString: extract qustrlen's attribute to a macro
I'll need it for the rest of the algorithms.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c1a2b31ac41c6d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-04 17:56:45 -08:00
Thiago Macieira 9d0c29b882 QString: remove the GCC 7 + ASan warning
GCC 7 is not supported in Qt 6, and I really don't expect
anyone would be using it in 2023 with ASan anyway.

Change-Id: I76216ced393445a4ae2dfffd1729a7b82a8776cc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-04 17:56:45 -08:00
Thiago Macieira 23555d9ac4 QString: reorganize the SSE2 helper functions
I'm going to need add a couple more, so move the block up.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c1942ca56a395b
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Thiago Macieira 0cd105079f QString: replace #if with if constexpr for the x86 ISA extensions
Because it looks like it works in all our compilers and gets us at least
basic syntax checking. This is important for me because I usually
compile with a very high -march= flag (currently, tigerlake) and would
not see any syntax errors I may introduce.

Whenever possible, this uses a return inside the if constexpr and then
has the fallback code simply eliminated, but still fully compiled.

Almost all changes are basic reindentation, except for a few variables
that must be declared above the block in question, plus some shenanigans
with the variables in qt_to_latin1_internal(): we want to avoid emitting
multiple loads for the same constants, so we force the compiler to reuse
the shrunk version of the 256-bit registers.

The non-AVX2 code will receive a few minor face-lifts in the next few
commits. Those don't intend to actually improve performance by much. The
real work will happen in the AVX2 code later. I dropped the -Os code
because I don't have the spare time to test it and maintain it; if
there's interest, we can simply disable the entire set vector
optimization set.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c1128c1a4d4875
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2022-12-04 17:56:45 -08:00
Mårten Nordheim e35cf5ebdc QByteArrayView: Add mid/left/right
Because they are too convenient to leave out.

Change-Id: I844cfb794ce0f575c2c65075d9051b0b878a434f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-02 20:53:01 +01:00
Mate Barany f192ddad8b QString: overload prepend with QUtf8StringView
Add the missing overload.

[ChangeLog][QtCore][QString] Added prepend(QUtf8StringView)
overload.

Task-number: QTBUG-103302
Change-Id: I3f74e884e514ebc0b15a13b074584d8272a02f41
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-02 16:04:14 +01:00
Mate Barany f046589e14 QString: overload insert with QUtf8StringView
Overloading insert is a bit tricky since the size might change after
the conversion so either the tail has to be moved twice or a temporary
buffer is needed. For now, add an ineffective but simple overload as in
the case of the const char *s overload, and do the performance
optimization in a follow-up task (QTBUG-108546).

[ChangeLog][QtCore][QString] Added insert(QUtf8StringView) overload.

Task-number: QTBUG-103302
Change-Id: If01c216ff626da29abb43eb68d4de82824f3bfba
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-02 16:04:11 +01:00
Mate Barany 2ffdb3bcdd QString: overload the += operator to handle QUtf8StringView
The += operator is already overloaded to handle QStringView and
QLatin1String - add the missing QUtf8StringView overload.

[ChangeLog][QtCore][QString] Added operator+=(QUtf8StringView)
overload.

Task-number: QTBUG-103302
Change-Id: Iec6940bad7866310c826a130b98accebc3c82aa8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-02 16:04:06 +01:00
Mate Barany d2e1d73bf1 QString: overload append to accept QUtf8StringView
Add the missing overload, among other things it is needed to
implement QTBUG-103302.

[ChangeLog][QtCore][QString] Added append(QUtf8StringView)
overload.

Task-number: QTBUG-103302
Change-Id: I576f73c1919e3a1f1a315d0f82c708e835686eb1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-12-02 16:04:01 +01:00
Øystein Heskestad b977ae371a Add In-place utf-8 case-insensitive comparisons
Also add optimizations for more string comparisons and add tests and
benchmarks.

[ChangeLog][QtCore][QString] Added utf-8 case-insensitive comparisons

Fixes: QTBUG-100235
Change-Id: I7c0809c6d80c00e9a5d0e8ac3ebb045cf7004a30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-02 11:35:49 +01:00
Marc Mutz 22ad2c3320 [doc] QAnyStringView: document visit()
For some reason, it wasn't documented.

Pick-to: 6.4 6.2
Change-Id: I480623398dc33be91e82b24ac2616bcdd20da34b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-12-02 10:34:39 +00:00
Marc Mutz 5d41ec46e9 QString/QByteArray: de-pessimize op+ [1/2]: non-const return types
const return types prevent move semantics, so drop the const.

This is BC, because the operators are all inline free functions. In
particular, they're not exported (MSVC mangles the return type).

[ChangeLog][QtCore][QString/QByteArray] operator+ no longer returns
a const object, enabling move-semantics on the return value, but also
hidden detaches.

Change-Id: Ifc18f6b1df1e3840f57b2521949dbade8e11fd76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-01 08:10:11 +00:00
Ahmad Samir d47061f62f QString: optimize replace() when both before and after have size == 1
By delegating to replace(QChar, QChar, cs).

Change-Id: I50b8f4031df3dd8042ddfcb55640f9edc853dc85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-11-30 15:48:51 +02:00
Giuseppe D'Angelo 3ccd1d2d83 QStringView::split: doc tidies
QStringView is a borrowed range, so views into it are always valid,
even if the QStringView itself is destroyed. Clarify the comment.
Fix another typo (referring to the view as "string") as well.

Pick-to: 6.2 6.4
Change-Id: I8a4f45494d44d5a47e3c1f764f12c899ad7ee83d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-11-30 13:48:51 +00:00
Vladimir Belyavsky 7d7ed24f51 QSystemLocale[Win]: Catch potential WinRT exceptions
Some Windows SDKs seem to throw an exception from winrt::check_hresult()
We need to handle this accordingly.

Fixes: QTBUG-108605
Pick-to: 6.2 6.4
Change-Id: I14ad3b6dbd9b5fdf0120f9d3336a4d922167d169
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-11-27 11:12:19 +03:00
Edward Welbourne e36457c043 Fix out-of-bounds assert in winIso639LangName()
QByteArray doesn't allow accessing, with operator[], the '\0' byte it
stores at index size(). Previously we accessed it indirectly by
dereferencing a pointer offset from its data() instead of indexing; my
recent change converted the return of an endptr to the return of its
index, so used operator[].

This is a follow-up to commit 6c435e5dd4

Change-Id: I9faf9dfa3dcc8df1e841e5538e452afef9ba610c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-11-25 14:28:48 +01:00
Ulf Hermann 6aa02bdeaf QLocale: Have qstrntod() return end of parsed string also on underflow
Underflows should be treated the same as overflows.

Fixes: QTBUG-108628
Change-Id: I23aa7bbe1d103778cefca08bd3e584e72f306583
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-11-25 10:55:39 +01:00
Friedemann Kleint 4a6ce541c5 Documentation: Fix information on how to iterate over lists
Remove the outdated code used for QStringList and point
QStringList and QList to the containers page.

Pick-to: 6.4 6.2
Task-number: QTBUG-108687
Change-Id: I6fae6410ca759f91da85832ddb9f24e8a0ce202b
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-11-24 19:12:20 +01:00