From 30c491f3b259f9472155271f42f2d867040481f6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 14 Nov 2022 14:56:14 -0800 Subject: [PATCH] QString: mark inline to{U,}LongLong() for inlining in Qt 7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original implementation of the toIntegral_helper() called these two functions, before we added the out-of-line non-template toIntegral_helper() overloads taking QStringView for Qt 5.15 in commit f1cbc3c9d24024b6bdd8d0346de9d7e548133459. They should have been inlined in Qt 6.0, but no one noticed this. Change-Id: Id8e48e8f498c4a029619fffd172795aaba2d815b Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Edward Welbourne --- src/corelib/compat/removed_api.cpp | 3 +++ src/corelib/text/qstring.cpp | 15 ++++----------- src/corelib/text/qstring.h | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 2204be9a3c..ddaa6ec61a 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -365,4 +365,7 @@ void QXmlStreamReader::addData(const char *data) #endif // QT_CONFIG(xmlstreamreader) +// inlined API +#include "qstring.h" + #endif // QT_CORE_REMOVED_SINCE(6, 5) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index bb5c0fe4ee..8b5c02324d 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -7158,6 +7158,8 @@ QString QString::vasprintf(const char *cformat, va_list ap) } /*! + \fn QString::toLongLong(bool *ok, int base) const + Returns the string converted to a \c{long long} using base \a base, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails. @@ -7184,11 +7186,6 @@ QString QString::vasprintf(const char *cformat, va_list ap) \sa number(), toULongLong(), toInt(), QLocale::toLongLong() */ -qint64 QString::toLongLong(bool *ok, int base) const -{ - return toIntegral_helper(*this, ok, base); -} - qlonglong QString::toIntegral_helper(QStringView string, bool *ok, int base) { #if defined(QT_CHECK_RANGE) @@ -7203,8 +7200,9 @@ qlonglong QString::toIntegral_helper(QStringView string, bool *ok, int base) return QLocaleData::bytearrayToLongLong(latin1, base, ok); } - /*! + \fn QString::toULongLong(bool *ok, int base) const + Returns the string converted to an \c{unsigned long long} using base \a base, which is 10 by default and must be between 2 and 36, or 0. Returns 0 if the conversion fails. @@ -7231,11 +7229,6 @@ qlonglong QString::toIntegral_helper(QStringView string, bool *ok, int base) \sa number(), toLongLong(), QLocale::toULongLong() */ -quint64 QString::toULongLong(bool *ok, int base) const -{ - return toIntegral_helper(*this, ok, base); -} - qulonglong QString::toIntegral_helper(QStringView string, bool *ok, uint base) { #if defined(QT_CHECK_RANGE) diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 300b54feb6..5f2ffd2760 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -882,7 +882,9 @@ public: { return toIntegral_helper(*this, ok, base); } ulong toULong(bool *ok=nullptr, int base=10) const { return toIntegral_helper(*this, ok, base); } + QT_CORE_INLINE_SINCE(6, 5) qlonglong toLongLong(bool *ok=nullptr, int base=10) const; + QT_CORE_INLINE_SINCE(6, 5) qulonglong toULongLong(bool *ok=nullptr, int base=10) const; float toFloat(bool *ok=nullptr) const; double toDouble(bool *ok=nullptr) const; @@ -1527,6 +1529,18 @@ inline int QString::localeAwareCompare(QStringView s1, QStringView s2) inline int QStringView::localeAwareCompare(QStringView other) const { return QString::localeAwareCompare(*this, other); } +#if QT_CORE_INLINE_IMPL_SINCE(6, 5) +qint64 QString::toLongLong(bool *ok, int base) const +{ + return toIntegral_helper(*this, ok, base); +} + +quint64 QString::toULongLong(bool *ok, int base) const +{ + return toIntegral_helper(*this, ok, base); +} +#endif + namespace QtPrivate { // used by qPrintable() and qUtf8Printable() macros inline const QString &asString(const QString &s) { return s; }