summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qanystringview.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-23 19:32:24 +0200
committerLars Knoll <lars.knoll@qt.io>2020-10-07 14:57:51 +0200
commit8a7b74f6e71d6b8264f365148bf5a04db4038617 (patch)
treebe16b5d1fb3299f75fa9641f5c113db4ed3791e0 /src/corelib/text/qanystringview.h
parent3807559d3779d2d6df4fb9180d2c4093ea1706ae (diff)
Optimize equality operators for string classes
Using compare() for those operators is not a good idea, as we can't shortcut comparisons if the string sizes are different. This alone made our HTML parser in QtGui around 15% slower. Don't go through QAnyStringView to implement compare() for QUtf8StringView, use QtPrivate::compareStrings() directly instead. Task-number: QTBUG-86354 Change-Id: I04869c29c9918161990dc1baf8e943b3a264ff3c Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Diffstat (limited to 'src/corelib/text/qanystringview.h')
-rw-r--r--src/corelib/text/qanystringview.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/text/qanystringview.h b/src/corelib/text/qanystringview.h
index 647f43f265..c073eda3b6 100644
--- a/src/corelib/text/qanystringview.h
+++ b/src/corelib/text/qanystringview.h
@@ -200,6 +200,7 @@ public:
[[nodiscard]] constexpr const void *data() const noexcept { return m_data; }
[[nodiscard]] Q_CORE_EXPORT static int compare(QAnyStringView lhs, QAnyStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+ [[nodiscard]] Q_CORE_EXPORT static bool equal(QAnyStringView lhs, QAnyStringView rhs) noexcept;
//
// STL compatibility API:
@@ -224,9 +225,9 @@ public:
private:
[[nodiscard]] friend inline bool operator==(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return QAnyStringView::compare(lhs, rhs) == 0; }
+ { return QAnyStringView::equal(lhs, rhs); }
[[nodiscard]] friend inline bool operator!=(QAnyStringView lhs, QAnyStringView rhs) noexcept
- { return !operator==(lhs, rhs); }
+ { return !QAnyStringView::equal(lhs, rhs); }
#ifdef __cpp_impl_three_way_comparison
[[nodiscard]] friend inline auto operator<=>(QAnyStringView lhs, QAnyStringView rhs) noexcept