@brief Calculates the distance to two pre-filtered match items * * @param a The CodeModelView witch represents the first item to be tested * @param b The CodeModelView witch represents the second item to be tested * * @b */
| 83 | * @b |
| 84 | */ |
| 85 | inline bool operator()(const CodeModelViewItem& a, const CodeModelViewItem& b) const |
| 86 | { |
| 87 | const int height_a = cache.value(a.m_id.index(), -1); |
| 88 | const int height_b = cache.value(b.m_id.index(), -1); |
| 89 | |
| 90 | Q_ASSERT(height_a != -1); |
| 91 | Q_ASSERT(height_b != -1); |
| 92 | |
| 93 | if (height_a == height_b) { |
| 94 | // stable sorting for equal items based on index |
| 95 | // TODO: fast string-based sorting in such cases? |
| 96 | return a.m_id.index() < b.m_id.index(); |
| 97 | } |
| 98 | |
| 99 | return height_a < height_b; |
| 100 | } |
| 101 | private: |
| 102 | const QHash<int, int>& cache; |
| 103 | }; |