diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-09-06 09:12:11 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-10-06 15:09:53 +0000 |
commit | 3c274d4e3eb01dfae44ed1bbcdda2fcdcc86b79b (patch) | |
tree | fc6318ab762b63c49e6dc601723afbe3e90f7669 /src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp | |
parent | 2d3be6a9897ee271c083c7fe11cf723a7c8665b3 (diff) |
QTableGenerator: give some TLC to the sorting predicate
- Provide op()(uint[], QComposeTableElement) as well, since the
standard (does|did) not specify in which order the two are called.
- Use std::lexicographical_compare to do the ... lexicographical
comparison.
- Share code by calling a new op()(uint[], uint[]) overload from all
other overloads.
- Mark all op() overloads const noexept.
- Rename from 'Compare' to 'ByKeys', as in 'sort(vector, ByKeys()))'.
- Replace a hand-rolled loop with std::equal.
- Replace a #define with a static constexpr variable.
Change-Id: I5ed487199916d0ae44ac38741fc95099bd2f8a22
Reviewed-by: Sune Vuorela <sune@vuorela.dk>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp')
-rw-r--r-- | src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp index 857f437661..6016d460fc 100644 --- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp @@ -155,11 +155,8 @@ void QComposeInputContext::update(Qt::InputMethodQueries q) static bool isDuplicate(const QComposeTableElement &lhs, const QComposeTableElement &rhs) { - for (size_t i = 0; i < QT_KEYSEQUENCE_MAX_LEN; i++) { - if (lhs.keys[i] != rhs.keys[i]) - return false; - } - return true; + return std::equal(lhs.keys, lhs.keys + QT_KEYSEQUENCE_MAX_LEN, + QT_MAKE_CHECKED_ARRAY_ITERATOR(rhs.keys, QT_KEYSEQUENCE_MAX_LEN)); } bool QComposeInputContext::checkComposeTable() @@ -182,7 +179,7 @@ bool QComposeInputContext::checkComposeTable() } Q_ASSERT(!m_composeTable.isEmpty()); QVector<QComposeTableElement>::const_iterator it = - std::lower_bound(m_composeTable.constBegin(), m_composeTable.constEnd(), m_composeBuffer, Compare()); + std::lower_bound(m_composeTable.constBegin(), m_composeTable.constEnd(), m_composeBuffer, ByKeys()); // prevent dereferencing an 'end' iterator, which would result in a crash if (it == m_composeTable.constEnd()) |