Q*StringView::contains: call the char overload of indexOf()

Avoids an unnecessary QStringView and possibly pessimizing the
code generation.

Pick-to: 6.10 6.9 6.8
Change-Id: Iac1ff680887641888e00fffd17e098972382bf10
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
Thiago Macieira 2024-07-09 09:33:06 -07:00
parent 48c3c81df0
commit e00ca26f9a
2 changed files with 2 additions and 2 deletions

View File

@ -131,7 +131,7 @@ public:
[[nodiscard]] bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != -1; }
[[nodiscard]] bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != -1; }
{ return indexOf(c, 0, cs) != -1; }
[[nodiscard]] qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return lastIndexOf(s, size(), cs); }

View File

@ -284,7 +284,7 @@ public:
[[nodiscard]] inline qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != qsizetype(-1); }
{ return indexOf(c, 0, cs) != qsizetype(-1); }
[[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != qsizetype(-1); }
[[nodiscard]] inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;