|
1 | 1 | #include "fzy.h" |
2 | 2 | #include <algorithm> |
3 | 3 | #include <array> |
4 | | -#include <bitset> |
5 | | - |
6 | | -#include <QVariant> |
| 4 | +#include <cmath> |
| 5 | +#include <limits> |
| 6 | + |
| 7 | +#include <qnamespace.h> |
| 8 | +#include <qstring.h> |
| 9 | +#include <qstringview.h> |
| 10 | +#include <qtypes.h> |
| 11 | +#include <qvariant.h> |
7 | 12 | #include <span> |
8 | 13 |
|
9 | 14 | namespace { |
@@ -90,7 +95,7 @@ void precomputeBonus(QStringView haystack, std::span<double> matchBonus) { |
90 | 95 | /* Which positions are beginning of words */ |
91 | 96 | QChar lastCh = '/'; |
92 | 97 | for (qsizetype index = 0; index < haystack.size(); index++) { |
93 | | - QChar ch = haystack[index]; |
| 98 | + const QChar ch = haystack[index]; |
94 | 99 | matchBonus[index] = getBonus(lastCh, ch); |
95 | 100 | lastCh = ch; |
96 | 101 | } |
@@ -119,15 +124,15 @@ void matchRow( |
119 | 124 | std::span<const double> lastD, |
120 | 125 | std::span<const double> lastM |
121 | 126 | ) { |
122 | | - qsizetype needleLen = match.lowerNeedle.size(); |
123 | | - qsizetype haystackLen = match.lowerHaystack.size(); |
| 127 | + const qsizetype needleLen = match.lowerNeedle.size(); |
| 128 | + const qsizetype haystackLen = match.lowerHaystack.size(); |
124 | 129 |
|
125 | | - QStringView lowerNeedle = match.lowerNeedle; |
126 | | - QStringView lowerHaystack = match.lowerHaystack; |
127 | | - std::span<const double> matchBonus = match.matchBonus; |
| 130 | + const QStringView lowerNeedle = match.lowerNeedle; |
| 131 | + const QStringView lowerHaystack = match.lowerHaystack; |
| 132 | + const std::span<const double> matchBonus = match.matchBonus; |
128 | 133 |
|
129 | 134 | double prevScore = SCORE_MIN; |
130 | | - double gapScore = row == needleLen - 1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; |
| 135 | + const double gapScore = row == needleLen - 1 ? SCORE_GAP_TRAILING : SCORE_GAP_INNER; |
131 | 136 |
|
132 | 137 | /* These will not be used with this value, but not all compilers see it */ |
133 | 138 | double prevM = SCORE_MIN; |
@@ -168,7 +173,7 @@ double match(QStringView needle, QStringView haystack) { |
168 | 173 | return SCORE_MAX; |
169 | 174 | } |
170 | 175 |
|
171 | | - MatchStruct match = setupMatchStruct(needle, haystack); |
| 176 | + const MatchStruct match = setupMatchStruct(needle, haystack); |
172 | 177 |
|
173 | 178 | /* |
174 | 179 | * D Stores the best score for this position ending with a match. |
@@ -198,7 +203,7 @@ FzyFinder::filter(const QString& needle, const QList<QObject*>& haystacks, const |
198 | 203 | } |
199 | 204 | } |
200 | 205 | std::ranges::stable_sort(list, std::ranges::greater(), &ScoredResult::score); |
201 | | - auto out = QList<QObject*>(static_cast<qsizetype>(list.size())); |
| 206 | + auto out = QList<QObject*>(list.size()); |
202 | 207 | std::ranges::transform(list, out.begin(), [](const ScoredResult& result) -> QObject* { |
203 | 208 | return result.obj; |
204 | 209 | }); |
|
0 commit comments