QLatin1StringView: un-inline Latin1-UTF8 compare_helper
Commit c630b231ec
("Untangle
QLatin1StringView from qstring.{h,cpp}") moved QLatin1StringView from
qstring.h, causing compilations that included qlatin1stringview.h but
not qstring.h to produce a warning.
By un-inlining, we get an improved comparison functionality without
memory allocation too. So win-win.
qlatin1stringview.h:325:23: warning: inline function ‘static int QLatin1String::compare_helper(const QLatin1StringView&, const char*)’ used but never defined
This is BC because the actual function that used to be inline continues
to be so, and the old implementation is fine, albeit slower.
Change-Id: Ieab617d69f3b4b54ab30fffd175c4e11d4a3b6dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4f00e6c8b9
commit
e2a76797e0
@ -321,9 +321,6 @@ public:
|
||||
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
|
||||
private:
|
||||
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
|
||||
static inline int compare_helper(const QLatin1StringView &s1, const char *s2);
|
||||
#endif
|
||||
Q_ALWAYS_INLINE constexpr void verify(qsizetype pos, qsizetype n = 0) const
|
||||
{
|
||||
Q_ASSERT(pos >= 0);
|
||||
@ -331,6 +328,9 @@ private:
|
||||
Q_ASSERT(n >= 0);
|
||||
Q_ASSERT(n <= size() - pos);
|
||||
}
|
||||
static int compare_helper(const QLatin1StringView &s1, const char *s2) noexcept
|
||||
{ return compare_helper(s1, s2, qstrlen(s2)); }
|
||||
Q_CORE_EXPORT static int compare_helper(const QLatin1StringView &s1, const char *s2, qsizetype len) noexcept;
|
||||
Q_CORE_EXPORT static int compare_helper(const QChar *data1, qsizetype length1,
|
||||
QLatin1StringView s2,
|
||||
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
|
||||
|
@ -6452,6 +6452,18 @@ int QString::compare_helper(const QChar *data1, qsizetype length1, const char *d
|
||||
\overload compare()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 6.6
|
||||
*/
|
||||
int QLatin1StringView::compare_helper(const QLatin1StringView &s1, const char *s2, qsizetype len) noexcept
|
||||
{
|
||||
// because qlatin1stringview.h can't include qutf8stringview.h
|
||||
Q_ASSERT(len >= 0);
|
||||
Q_ASSERT(s2 || len == 0);
|
||||
return QtPrivate::compareStrings(s1, QUtf8StringView(s2, len));
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 4.5
|
||||
|
@ -1177,12 +1177,6 @@ QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator<=(const QByteArray &s
|
||||
QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator>=(const QByteArray &s) const
|
||||
{ return QString::fromUtf8(s) <= *this; }
|
||||
|
||||
inline int QLatin1StringView::compare_helper(const QLatin1StringView &s1, const char *s2)
|
||||
{
|
||||
return QString::compare(s1, QString::fromUtf8(s2));
|
||||
}
|
||||
|
||||
|
||||
QT_ASCII_CAST_WARN inline bool QString::operator==(const QByteArray &s) const
|
||||
{ return QString::compare_helper(constData(), size(), s.constData(), s.size()) == 0; }
|
||||
QT_ASCII_CAST_WARN inline bool QString::operator!=(const QByteArray &s) const
|
||||
|
Loading…
Reference in New Issue
Block a user