Skip to content

Commit eedcf8f

Browse files
committed
improve calculation of min score inside partial_ratio so it can skip more alignments
1 parent 03d037a commit eedcf8f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Changelog
22

3+
## [3.2.0] -
4+
### Performance
5+
- improve calculation of min score inside partial_ratio so it can skip more alignments
6+
37
## [3.1.1] - 2024-10-24
48
### Fixed
59
- Fixed incorrect score calculation for SIMD implementations of Levenshtein and OSA on 32 bit systems

extras/rapidfuzz_amalgamated.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
22
// SPDX-License-Identifier: MIT
33
// RapidFuzz v1.0.2
4-
// Generated: 2024-10-24 15:27:27.715931
4+
// Generated: 2024-12-14 13:57:57.746331
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -10281,9 +10281,10 @@ partial_ratio_impl(const detail::Range<InputIt1>& s1, const detail::Range<InputI
1028110281
/* find the minimum score possible in the range first <-> last */
1028210282
size_t known_edits = detail::abs_diff(scores[window.first], scores[window.second]);
1028310283
/* half of the cells that are not needed for known_edits can lead to a better score */
10284+
size_t max_score_improvement = (cell_diff - known_edits / 2) / 2 * 2;
1028410285
ptrdiff_t min_score =
1028510286
static_cast<ptrdiff_t>(std::min(scores[window.first], scores[window.second])) -
10286-
static_cast<ptrdiff_t>(cell_diff + known_edits / 2);
10287+
static_cast<ptrdiff_t>(max_score_improvement);
1028710288
if (min_score < static_cast<ptrdiff_t>(cutoff_dist)) {
1028810289
size_t center = cell_diff / 2;
1028910290
new_windows.emplace_back(window.first, window.first + center);

rapidfuzz/fuzz_impl.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ partial_ratio_impl(const detail::Range<InputIt1>& s1, const detail::Range<InputI
124124
/* find the minimum score possible in the range first <-> last */
125125
size_t known_edits = detail::abs_diff(scores[window.first], scores[window.second]);
126126
/* half of the cells that are not needed for known_edits can lead to a better score */
127+
size_t max_score_improvement = (cell_diff - known_edits / 2) / 2 * 2;
127128
ptrdiff_t min_score =
128129
static_cast<ptrdiff_t>(std::min(scores[window.first], scores[window.second])) -
129-
static_cast<ptrdiff_t>(cell_diff + known_edits / 2);
130+
static_cast<ptrdiff_t>(max_score_improvement);
130131
if (min_score < static_cast<ptrdiff_t>(cutoff_dist)) {
131132
size_t center = cell_diff / 2;
132133
new_windows.emplace_back(window.first, window.first + center);

0 commit comments

Comments
 (0)