summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-03-09 21:26:01 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2022-03-26 01:44:05 +0100
commitb6251958932be5966258f362dc9bb7c7475d2d0a (patch)
tree2b2dc46c0d097fca15bcc9e2701682919921c339 /src/corelib/tools
parent73a03a0c298461aa15d7c2757bc0b6444e5dc3dc (diff)
QtCore: Replace remaining uses of QLatin1String with QLatin1StringView
Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp2
-rw-r--r--src/corelib/tools/qhash.cpp4
-rw-r--r--src/corelib/tools/qhashfunctions.h4
-rw-r--r--src/corelib/tools/qversionnumber.cpp8
-rw-r--r--src/corelib/tools/qversionnumber.h2
5 files changed, 10 insertions, 10 deletions
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 92f391c39a..3a222aecbc 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -1153,7 +1153,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
QString optionNamesString;
for (const QString &optionName : optionNames) {
const int numDashes = optionName.length() == 1 ? 1 : 2;
- optionNamesString += QLatin1String("--", numDashes) + optionName + ", "_L1;
+ optionNamesString += QLatin1StringView("--", numDashes) + optionName + ", "_L1;
}
if (!optionNames.isEmpty())
optionNamesString.chop(2); // remove trailing ", "
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 6ee0dc4670..eb9c1590d2 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -1019,7 +1019,7 @@ size_t qHash(const QBitArray &bitArray, size_t seed) noexcept
return result;
}
-size_t qHash(QLatin1String key, size_t seed) noexcept
+size_t qHash(QLatin1StringView key, size_t seed) noexcept
{
return qHashBits(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed);
}
@@ -1541,7 +1541,7 @@ size_t qHash(long double key, size_t seed) noexcept
Returns the hash value for the \a key, using \a seed to seed the calculation.
*/
-/*! \fn size_t qHash(QLatin1String key, size_t seed = 0)
+/*! \fn size_t qHash(QLatin1StringView key, size_t seed = 0)
\relates QHash
\since 5.0
diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h
index 7aecd2c012..4204fa7c0a 100644
--- a/src/corelib/tools/qhashfunctions.h
+++ b/src/corelib/tools/qhashfunctions.h
@@ -188,7 +188,7 @@ inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) no
{ return qHash(QStringView{key}, seed); }
#endif
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept;
-Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept;
+Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1StringView key, size_t seed = 0) noexcept;
Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept
{ return qHash(key.toCombined(), seed); }
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept;
@@ -340,7 +340,7 @@ template <typename T1, typename T2> inline size_t qHash(const std::pair<T1, T2>
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QString)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QStringView)
-QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1String)
+QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1StringView)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QByteArray)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QBitArray)
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 784022f7bd..7ec0e45dd1 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -424,12 +424,12 @@ QString QVersionNumber::toString() const
\snippet qversionnumber/main.cpp 3-latin1-1
\note In versions prior to Qt 6.4, this function was overloaded for QString,
- QLatin1String and QStringView instead, and \a suffixIndex was an \c{int*}.
+ QLatin1StringView and QStringView instead, and \a suffixIndex was an \c{int*}.
\sa isNull()
*/
-static QVersionNumber from_string(QLatin1String string, qsizetype *suffixIndex)
+static QVersionNumber from_string(QLatin1StringView string, qsizetype *suffixIndex)
{
// 32 should be more than enough, and, crucially, it means we're allocating
// not more (and often less) often when compared with direct QList usage
@@ -462,7 +462,7 @@ static QVersionNumber from_string(QLatin1String string, qsizetype *suffixIndex)
static QVersionNumber from_string(q_no_char8_t::QUtf8StringView string, qsizetype *suffixIndex)
{
- return from_string(QLatin1String(string.data(), string.size()), suffixIndex);
+ return from_string(QLatin1StringView(string.data(), string.size()), suffixIndex);
}
// in qstring.cpp
@@ -473,7 +473,7 @@ static QVersionNumber from_string(QStringView string, qsizetype *suffixIndex)
QVarLengthArray<char> copy;
copy.resize(string.size());
qt_to_latin1(reinterpret_cast<uchar*>(copy.data()), string.utf16(), string.size());
- return from_string(QLatin1String(copy.data(), copy.size()), suffixIndex);
+ return from_string(QLatin1StringView(copy.data(), copy.size()), suffixIndex);
}
QVersionNumber QVersionNumber::fromString(QAnyStringView string, qsizetype *suffixIndex)
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index 559a09d750..c00587c300 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -307,7 +307,7 @@ public:
#if QT_CORE_REMOVED_SINCE(6, 4)
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex);
- [[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex);
+ [[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QLatin1StringView string, int *suffixIndex);
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex);
#endif