Skip to content

Commit 6dc8807

Browse files
committed
replace unsupported std::equals overload
1 parent fcff9f2 commit 6dc8807

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ add_library(rapidfuzz INTERFACE)
5050
# provide a namespaced alias for clients to 'link' against if RapidFuzz is included as a sub-project
5151
add_library(rapidfuzz::rapidfuzz ALIAS rapidfuzz)
5252

53-
target_compile_features(rapidfuzz INTERFACE cxx_std_14)
53+
target_compile_features(rapidfuzz INTERFACE cxx_std_11)
5454

5555
target_include_directories(rapidfuzz
5656
INTERFACE

fuzzing/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function(create_fuzzer fuzzer)
22
add_executable(fuzz_${fuzzer} fuzz_${fuzzer}.cpp)
3-
target_compile_features(fuzz_${fuzzer} PUBLIC cxx_std_14)
3+
target_compile_features(fuzz_${fuzzer} PUBLIC cxx_std_11)
44
target_link_libraries(fuzz_${fuzzer} PRIVATE rapidfuzz::rapidfuzz)
55

66
target_compile_options(fuzz_${fuzzer} PRIVATE -g -O1 -fsanitize=fuzzer,address -march=native)

rapidfuzz/details/Range.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ Range(T& x) -> Range<decltype(to_begin(x))>;
180180
template <typename InputIt1, typename InputIt2>
181181
inline bool operator==(const Range<InputIt1>& a, const Range<InputIt2>& b)
182182
{
183-
return std::equal(a.begin(), a.end(), b.begin(), b.end());
183+
if (a.size() != b.size()) return false;
184+
185+
return std::equal(a.begin(), a.end(), b.begin());
184186
}
185187

186188
template <typename InputIt1, typename InputIt2>

rapidfuzz/details/types.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,10 @@ class Editops : private std::vector<EditOp> {
337337

338338
inline bool operator==(const Editops& lhs, const Editops& rhs)
339339
{
340-
if (lhs.get_src_len() != rhs.get_src_len() || lhs.get_dest_len() != rhs.get_dest_len()) {
341-
return false;
342-
}
340+
if (lhs.get_src_len() != rhs.get_src_len() || lhs.get_dest_len() != rhs.get_dest_len()) return false;
341+
342+
if (lhs.size() != rhs.size()) return false;
343343

344-
if (lhs.size() != rhs.size()) {
345-
return false;
346-
}
347344
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
348345
}
349346

rapidfuzz/distance/LCSseq_impl.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ size_t lcs_seq_similarity(const BlockPatternMatchVector& block, Range<InputIt1>
384384
size_t max_misses = len1 + len2 - 2 * score_cutoff;
385385

386386
/* no edits are allowed */
387-
if (max_misses == 0 || (max_misses == 1 && len1 == len2))
388-
return std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) ? len1 : 0;
387+
if (max_misses == 0 || (max_misses == 1 && len1 == len2)) return s1 == s2 ? len1 : 0;
389388

390389
if (max_misses < abs_diff(len1, len2)) return 0;
391390

@@ -417,8 +416,7 @@ size_t lcs_seq_similarity(Range<InputIt1> s1, Range<InputIt2> s2, size_t score_c
417416
size_t max_misses = len1 + len2 - 2 * score_cutoff;
418417

419418
/* no edits are allowed */
420-
if (max_misses == 0 || (max_misses == 1 && len1 == len2))
421-
return std::equal(s1.begin(), s1.end(), s2.begin(), s2.end()) ? len1 : 0;
419+
if (max_misses == 0 || (max_misses == 1 && len1 == len2)) return s1 == s2 ? len1 : 0;
422420

423421
if (max_misses < abs_diff(len1, len2)) return 0;
424422

rapidfuzz/distance/Levenshtein_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ size_t uniform_levenshtein_distance(const BlockPatternMatchVector& block, Range<
858858
if (score_hint < 31) score_hint = 31;
859859

860860
// when no differences are allowed a direct comparision is sufficient
861-
if (score_cutoff == 0) return !std::equal(s1.begin(), s1.end(), s2.begin(), s2.end());
861+
if (score_cutoff == 0) return s1 != s2;
862862

863863
if (score_cutoff < abs_diff(s1.size(), s2.size())) return score_cutoff + 1;
864864

@@ -916,7 +916,7 @@ size_t uniform_levenshtein_distance(Range<InputIt1> s1, Range<InputIt2> s2, size
916916
if (score_hint < 31) score_hint = 31;
917917

918918
// when no differences are allowed a direct comparision is sufficient
919-
if (score_cutoff == 0) return !std::equal(s1.begin(), s1.end(), s2.begin(), s2.end());
919+
if (score_cutoff == 0) return s1 != s2;
920920

921921
// at least length difference insertions/deletions required
922922
if (score_cutoff < (s1.size() - s2.size())) return score_cutoff + 1;

0 commit comments

Comments
 (0)