diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2024-02-28 09:06:05 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-03-04 11:31:48 -0800 |
commit | a6b4ff16b9f6ba7f93d55c0eedb5ef44f2d85c99 (patch) | |
tree | 37495bf3d720bce7848369bc9c76708c0b1fcede /src/plugins/platforms | |
parent | a14bba6803f674edede596eaeb5a46feed0f889e (diff) |
Replace some QString::fromUtf16() with QStringView::toString()
The QStringView counterpart is somewhat faster because it doesn't go
through the UTF-16 codec in QUtf16::convertToUnicode(), which tries to
detect the BOM.
I've included QString::fromWCharArray in this because:
a) it's used extensively in Windows code
b) wide chars in memory probably don't have BOMs anyway
Change-Id: I01ec3c774d9943adb903fffd17b815be4d2ab8ba
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbmime.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 3e3223d363..860d195d13 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -155,7 +155,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, const quint8 byte1 = data.at(1); if ((byte0 == 0xff && byte1 == 0xfe) || (byte0 == 0xfe && byte1 == 0xff) || (byte0 != 0 && byte1 == 0) || (byte0 == 0 && byte1 != 0)) { - const QString str = QString::fromUtf16( + const QStringView str( reinterpret_cast<const char16_t *>(data.constData()), data.size() / 2); if (!str.isNull()) { if (format == "text/uri-list"_L1) { @@ -174,7 +174,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, return list.constFirst(); return list; } else { - return str; + return str.toString(); } } } |