From 39e229fe13a2112dcc5d033f4535fd019aab800b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 22 May 2020 14:24:01 +0200 Subject: [PATCH] Remove more QStringRef overloads that aren't required The QStringView versions will do the job just fine :) Task-number: QTBUG-84319 Change-Id: I376b310deb27683fd98bbcc55e0f56014cacecc3 Reviewed-by: Alex Blasche --- src/corelib/io/qdebug.cpp | 14 -- src/corelib/io/qdebug.h | 1 - src/corelib/serialization/qtextstream.cpp | 15 -- src/corelib/serialization/qtextstream.h | 1 - src/corelib/text/qcollator.cpp | 13 -- src/corelib/text/qcollator.h | 1 - src/corelib/text/qlocale.cpp | 217 ---------------------- src/corelib/text/qlocale.h | 11 -- 8 files changed, 273 deletions(-) diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 11f2b9f3c9..e8933b4526 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -633,20 +633,6 @@ QDebug &QDebug::resetFormat() \snippet code/src_corelib_io_qdebug.cpp 0 */ -/*! - \fn QDebug &QDebug::operator<<(const QStringRef &t) - - Writes the string, \a t, to the stream and returns a reference to the - stream. Normally, QDebug prints the string inside quotes and transforms - non-printable characters to their Unicode values (\\u1234). - - To print non-printable characters without transformation, enable the - noquote() functionality. Note that some QDebug backends might not be 8-bit - clean. - - See the QString overload for examples. -*/ - /*! \since 5.10 \fn QDebug &QDebug::operator<<(QStringView s) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 22ba3879f4..9ee19f5fd4 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -158,7 +158,6 @@ public: inline QDebug &operator<<(const char* t) { stream->ts << QString::fromUtf8(t); return maybeSpace(); } #if QT_STRINGVIEW_LEVEL < 2 inline QDebug &operator<<(const QString & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } - inline QDebug &operator<<(const QStringRef & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } #endif inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); } inline QDebug &operator<<(QLatin1String t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 5dd388c70c..3f0c25fd17 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -2541,21 +2541,6 @@ QTextStream &QTextStream::operator<<(QLatin1String string) return *this; } -/*! - \since 5.6 - \overload - - Writes \a string to the stream, and returns a reference to the - QTextStream. -*/ -QTextStream &QTextStream::operator<<(const QStringRef &string) -{ - Q_D(QTextStream); - CHECK_VALID_STREAM(*this); - d->putString(string.data(), string.size()); - return *this; -} - /*! \overload diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index 2b164ce9b3..1d13ed896c 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -180,7 +180,6 @@ public: QTextStream &operator<<(const QString &s); QTextStream &operator<<(QStringView s); QTextStream &operator<<(QLatin1String s); - QTextStream &operator<<(const QStringRef &s); QTextStream &operator<<(const QByteArray &array); QTextStream &operator<<(const char *c); QTextStream &operator<<(const void *ptr); diff --git a/src/corelib/text/qcollator.cpp b/src/corelib/text/qcollator.cpp index 958216bde8..4bef356044 100644 --- a/src/corelib/text/qcollator.cpp +++ b/src/corelib/text/qcollator.cpp @@ -326,19 +326,6 @@ int QCollator::compare(const QString &s1, const QString &s2) const return compare(QStringView(s1), QStringView(s2)); } -/*! - \overload - - Compares \a s1 with \a s2. - - Returns an integer less than, equal to, or greater than zero depending on - whether \a s1 sorts before, with or after \a s2. - */ -int QCollator::compare(const QStringRef &s1, const QStringRef &s2) const -{ - return compare(QStringView(s1), QStringView(s2)); -} - /*! \overload diff --git a/src/corelib/text/qcollator.h b/src/corelib/text/qcollator.h index 6bb5038371..de8c8b7e3c 100644 --- a/src/corelib/text/qcollator.h +++ b/src/corelib/text/qcollator.h @@ -108,7 +108,6 @@ public: #if QT_STRINGVIEW_LEVEL < 2 int compare(const QString &s1, const QString &s2) const; - int compare(const QStringRef &s1, const QStringRef &s2) const; int compare(const QChar *s1, int len1, const QChar *s2, int len2) const; bool operator()(const QString &s1, const QString &s2) const diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index a2cf2caec0..8217641aa3 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1582,223 +1582,6 @@ double QLocale::toDouble(const QString &s, bool *ok) const { return d->m_data->stringToDouble(s, ok, d->m_numberOptions); } - -/*! - Returns the short int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toUShort(), toString() - - \since 5.1 -*/ - -short QLocale::toShort(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the unsigned short int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toShort(), toString() - - \since 5.1 -*/ - -ushort QLocale::toUShort(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toUInt(), toString() - - \since 5.1 -*/ - -int QLocale::toInt(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the unsigned int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toInt(), toString() - - \since 5.1 -*/ - -uint QLocale::toUInt(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the long int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toInt(), toULong(), toDouble(), toString() - - \since 5.13 - */ - - -long QLocale::toLong(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the unsigned long int represented by the localized - string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toLong(), toInt(), toDouble(), toString() - - \since 5.13 - */ - -ulong QLocale::toULong(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the long long int represented by the localized string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toInt(), toULongLong(), toDouble(), toString() - - \since 5.1 -*/ - - -qlonglong QLocale::toLongLong(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the unsigned long long int represented by the localized - string \a s. - - If the conversion fails the function returns 0. - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function ignores leading and trailing whitespace. - - \sa toLongLong(), toInt(), toDouble(), toString() - - \since 5.1 -*/ - -qulonglong QLocale::toULongLong(const QStringRef &s, bool *ok) const -{ - return toIntegral_helper(d, s, ok); -} - -/*! - Returns the float represented by the localized string \a s. - - Returns an infinity if the conversion overflows or 0.0 if the - conversion fails for any other reason (e.g. underflow). - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function does not fall back to the 'C' locale if the string - cannot be interpreted in this locale. - - This function ignores leading and trailing whitespace. - - \sa toDouble(), toInt(), toString() - - \since 5.1 -*/ - -float QLocale::toFloat(const QStringRef &s, bool *ok) const -{ - return QLocaleData::convertDoubleToFloat(toDouble(s, ok), ok); -} - -/*! - Returns the double represented by the localized string \a s. - - Returns an infinity if the conversion overflows or 0.0 if the - conversion fails for any other reason (e.g. underflow). - - If \a ok is not \nullptr, failure is reported by setting *\a{ok} - to \c false, and success by setting *\a{ok} to \c true. - - This function does not fall back to the 'C' locale if the string - cannot be interpreted in this locale. - - \snippet code/src_corelib_text_qlocale.cpp 3 - - Notice that the last conversion returns 1234.0, because '.' is the - thousands group separator in the German locale. - - This function ignores leading and trailing whitespace. - - \sa toFloat(), toInt(), toString() - - \since 5.1 -*/ - -double QLocale::toDouble(const QStringRef &s, bool *ok) const -{ - return d->m_data->stringToDouble(s, ok, d->m_numberOptions); -} #endif // QT_STRINGVIEW_LEVEL < 2 /*! diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index 509e19b4ba..ee7e978e48 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -971,17 +971,6 @@ public: qulonglong toULongLong(const QString &s, bool *ok = nullptr) const; float toFloat(const QString &s, bool *ok = nullptr) const; double toDouble(const QString &s, bool *ok = nullptr) const; - - short toShort(const QStringRef &s, bool *ok = nullptr) const; - ushort toUShort(const QStringRef &s, bool *ok = nullptr) const; - int toInt(const QStringRef &s, bool *ok = nullptr) const; - uint toUInt(const QStringRef &s, bool *ok = nullptr) const; - long toLong(const QStringRef &s, bool *ok = nullptr) const; - ulong toULong(const QStringRef &s, bool *ok = nullptr) const; - qlonglong toLongLong(const QStringRef &s, bool *ok = nullptr) const; - qulonglong toULongLong(const QStringRef &s, bool *ok = nullptr) const; - float toFloat(const QStringRef &s, bool *ok = nullptr) const; - double toDouble(const QStringRef &s, bool *ok = nullptr) const; #endif short toShort(QStringView s, bool *ok = nullptr) const;