Skip to content

Commit

Permalink
remove usage of [[maybe_unused]]
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Dec 25, 2024
1 parent e08f222 commit 2647a66
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 123 deletions.
105 changes: 43 additions & 62 deletions extras/rapidfuzz_amalgamated.hpp

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions rapidfuzz/distance/DamerauLevenshtein.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ struct CachedDamerauLevenshtein : public detail::CachedDistanceBase<CachedDamera
}

template <typename InputIt2>
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff, size_t) const
{
return rapidfuzz::experimental::damerau_levenshtein_distance(s1, s2, score_cutoff);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/DamerauLevenshtein_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class DamerauLevenshtein
}

template <typename InputIt1, typename InputIt2>
static size_t _distance(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint)
static size_t _distance(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t score_cutoff, size_t)
{
return damerau_levenshtein_distance(s1, s2, score_cutoff);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/Hamming.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ struct CachedHamming : public detail::CachedDistanceBase<CachedHamming<CharT1>,
}

template <typename InputIt2>
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff, size_t score_hint) const
{
return detail::Hamming::distance(s1, s2, pad, score_cutoff, score_hint);
}
Expand Down
2 changes: 1 addition & 1 deletion rapidfuzz/distance/Hamming_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Hamming : public DistanceBase<Hamming, size_t, 0, std::numeric_limits<int6

template <typename InputIt1, typename InputIt2>
static size_t _distance(const Range<InputIt1>& s1, const Range<InputIt2>& s2, bool pad,
size_t score_cutoff, [[maybe_unused]] size_t score_hint)
size_t score_cutoff, size_t)
{
if (!pad && s1.size() != s2.size()) throw std::invalid_argument("Sequences are not the same length.");

Expand Down
5 changes: 2 additions & 3 deletions rapidfuzz/distance/Jaro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ struct MultiJaro : public detail::MultiSimilarityBase<MultiJaro<MaxLen>, double,
}

template <typename InputIt2>
double maximum([[maybe_unused]] size_t s1_idx, const detail::Range<InputIt2>&) const
double maximum(size_t, const detail::Range<InputIt2>&) const
{
return 1.0;
}
Expand Down Expand Up @@ -213,8 +213,7 @@ struct CachedJaro : public detail::CachedSimilarityBase<CachedJaro<CharT1>, doub
}

template <typename InputIt2>
double _similarity(const detail::Range<InputIt2>& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double _similarity(const detail::Range<InputIt2>& s2, double score_cutoff, double) const
{
return detail::jaro_similarity(PM, detail::make_range(s1), s2, score_cutoff);
}
Expand Down
5 changes: 2 additions & 3 deletions rapidfuzz/distance/JaroWinkler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct MultiJaroWinkler : public detail::MultiSimilarityBase<MultiJaroWinkler<Ma
}

template <typename InputIt2>
double maximum([[maybe_unused]] size_t s1_idx, const detail::Range<InputIt2>&) const
double maximum(size_t, const detail::Range<InputIt2>&) const
{
return 1.0;
}
Expand Down Expand Up @@ -188,8 +188,7 @@ struct CachedJaroWinkler : public detail::CachedSimilarityBase<CachedJaroWinkler
}

template <typename InputIt2>
double _similarity(const detail::Range<InputIt2>& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double _similarity(const detail::Range<InputIt2>& s2, double score_cutoff, double) const
{
return detail::jaro_winkler_similarity(PM, detail::make_range(s1), s2, prefix_weight, score_cutoff);
}
Expand Down
2 changes: 1 addition & 1 deletion rapidfuzz/distance/JaroWinkler_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class JaroWinkler : public SimilarityBase<JaroWinkler, double, 0, 1, double> {

template <typename InputIt1, typename InputIt2>
static double _similarity(const Range<InputIt1>& s1, const Range<InputIt2>& s2, double prefix_weight,
double score_cutoff, [[maybe_unused]] double score_hint)
double score_cutoff, double)
{
return jaro_winkler_similarity(s1, s2, prefix_weight, score_cutoff);
}
Expand Down
9 changes: 5 additions & 4 deletions rapidfuzz/distance/Jaro_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ static inline size_t count_common_chars(const FlaggedCharsMultiword& flagged)
}

template <typename PM_Vec, typename InputIt1, typename InputIt2>
static inline FlaggedCharsWord flag_similar_characters_word(const PM_Vec& PM,
[[maybe_unused]] const Range<InputIt1>& P,
static inline FlaggedCharsWord flag_similar_characters_word(const PM_Vec& PM, const Range<InputIt1>&,
const Range<InputIt2>& T, size_t Bound)
{
assert(P.size() <= 64);
Expand Down Expand Up @@ -472,7 +471,9 @@ static inline auto jaro_similarity_prepare_bound_short_s2(const VecType* s1_leng
using namespace simd_sse2;
# endif

[[maybe_unused]] static constexpr size_t alignment = native_simd<VecType>::alignment;
# ifndef RAPIDFUZZ_AVX2
static constexpr size_t alignment = native_simd<VecType>::alignment;
# endif
static constexpr size_t vec_width = native_simd<VecType>::size;
assert(s2.size() <= sizeof(VecType) * 8);

Expand Down Expand Up @@ -847,7 +848,7 @@ class Jaro : public SimilarityBase<Jaro, double, 0, 1> {

template <typename InputIt1, typename InputIt2>
static double _similarity(const Range<InputIt1>& s1, const Range<InputIt2>& s2, double score_cutoff,
[[maybe_unused]] double score_hint)
double)
{
return jaro_similarity(s1, s2, score_cutoff);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/LCSseq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ struct CachedLCSseq
}

template <typename InputIt2>
size_t _similarity(const detail::Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _similarity(const detail::Range<InputIt2>& s2, size_t score_cutoff, size_t) const
{
return detail::lcs_seq_similarity(PM, detail::make_range(s1), s2, score_cutoff);
}
Expand Down
6 changes: 4 additions & 2 deletions rapidfuzz/distance/LCSseq_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ Editops recover_alignment(const Range<InputIt1>& s1, const Range<InputIt2>& s2,

if (dist == 0) return editops;

[[maybe_unused]] size_t band_width_right = s2.size() - matrix.sim;
#ifndef NDEBUG
size_t band_width_right = s2.size() - matrix.sim;
#endif

auto col = len1;
auto row = len2;
Expand Down Expand Up @@ -549,7 +551,7 @@ class LCSseq : public SimilarityBase<LCSseq, size_t, 0, std::numeric_limits<int6

template <typename InputIt1, typename InputIt2>
static size_t _similarity(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint)
size_t)
{
return lcs_seq_similarity(s1, s2, score_cutoff);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/OSA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ struct CachedOSA
}

template <typename InputIt2>
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _distance(const detail::Range<InputIt2>& s2, size_t score_cutoff, size_t) const
{
size_t res;
if (s1.empty())
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/Postfix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ struct CachedPostfix : public detail::CachedSimilarityBase<CachedPostfix<CharT1>
}

template <typename InputIt2>
size_t _similarity(detail::Range<InputIt2> s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _similarity(detail::Range<InputIt2> s2, size_t score_cutoff, size_t score_hint) const
{
return detail::Postfix::similarity(s1, s2, score_cutoff, score_hint);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/Postfix_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class Postfix : public SimilarityBase<Postfix, size_t, 0, std::numeric_limits<in
}

template <typename InputIt1, typename InputIt2>
static size_t _similarity(Range<InputIt1> s1, Range<InputIt2> s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint)
static size_t _similarity(Range<InputIt1> s1, Range<InputIt2> s2, size_t score_cutoff, size_t)
{
size_t dist = remove_common_suffix(s1, s2);
return (dist >= score_cutoff) ? dist : 0;
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/Prefix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ struct CachedPrefix : public detail::CachedSimilarityBase<CachedPrefix<CharT1>,
}

template <typename InputIt2>
size_t _similarity(detail::Range<InputIt2> s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint) const
size_t _similarity(detail::Range<InputIt2> s2, size_t score_cutoff, size_t) const
{
return detail::Prefix::similarity(s1, s2, score_cutoff, score_cutoff);
}
Expand Down
3 changes: 1 addition & 2 deletions rapidfuzz/distance/Prefix_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class Prefix : public SimilarityBase<Prefix, size_t, 0, std::numeric_limits<int6
}

template <typename InputIt1, typename InputIt2>
static size_t _similarity(Range<InputIt1> s1, Range<InputIt2> s2, size_t score_cutoff,
[[maybe_unused]] size_t score_hint)
static size_t _similarity(Range<InputIt1> s1, Range<InputIt2> s2, size_t score_cutoff, size_t)
{
size_t dist = remove_common_prefix(s1, s2);
return (dist >= score_cutoff) ? dist : 0;
Expand Down
47 changes: 18 additions & 29 deletions rapidfuzz/fuzz_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ CachedPartialRatio<CharT1>::CachedPartialRatio(InputIt1 first1, InputIt1 last1)
template <typename CharT1>
template <typename InputIt2>
double CachedPartialRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
size_t len1 = s1.size();
size_t len2 = static_cast<size_t>(std::distance(first2, last2));
Expand All @@ -286,8 +286,7 @@ double CachedPartialRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, d

template <typename CharT1>
template <typename Sentence2>
double CachedPartialRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedPartialRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand All @@ -314,7 +313,7 @@ double token_sort_ratio(const Sentence1& s1, const Sentence2& s2, double score_c
template <typename CharT1>
template <typename InputIt2>
double CachedTokenSortRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
if (score_cutoff > 100) return 0;

Expand All @@ -323,8 +322,7 @@ double CachedTokenSortRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2,

template <typename CharT1>
template <typename Sentence2>
double CachedTokenSortRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedTokenSortRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -353,7 +351,7 @@ double partial_token_sort_ratio(const Sentence1& s1, const Sentence2& s2, double
template <typename CharT1>
template <typename InputIt2>
double CachedPartialTokenSortRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
if (score_cutoff > 100) return 0;

Expand All @@ -362,8 +360,7 @@ double CachedPartialTokenSortRatio<CharT1>::similarity(InputIt2 first2, InputIt2

template <typename CharT1>
template <typename Sentence2>
double CachedPartialTokenSortRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedPartialTokenSortRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -442,7 +439,7 @@ double token_set_ratio(const Sentence1& s1, const Sentence2& s2, double score_cu
template <typename CharT1>
template <typename InputIt2>
double CachedTokenSetRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
if (score_cutoff > 100) return 0;

Expand All @@ -451,8 +448,7 @@ double CachedTokenSetRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2,

template <typename CharT1>
template <typename Sentence2>
double CachedTokenSetRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedTokenSetRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -501,7 +497,7 @@ double partial_token_set_ratio(const Sentence1& s1, const Sentence2& s2, double
template <typename CharT1>
template <typename InputIt2>
double CachedPartialTokenSetRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
if (score_cutoff > 100) return 0;

Expand All @@ -510,8 +506,7 @@ double CachedPartialTokenSetRatio<CharT1>::similarity(InputIt2 first2, InputIt2

template <typename CharT1>
template <typename Sentence2>
double CachedPartialTokenSetRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedPartialTokenSetRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -690,15 +685,14 @@ double token_ratio(const std::vector<CharT1>& s1_sorted,
template <typename CharT1>
template <typename InputIt2>
double CachedTokenRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
return fuzz_detail::token_ratio(s1_tokens, cached_ratio_s1_sorted, first2, last2, score_cutoff);
}

template <typename CharT1>
template <typename Sentence2>
double CachedTokenRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedTokenRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -776,15 +770,14 @@ double partial_token_ratio(const std::vector<CharT1>& s1_sorted,
template <typename CharT1>
template <typename InputIt2>
double CachedPartialTokenRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double) const
{
return fuzz_detail::partial_token_ratio(s1_sorted, tokens_s1, first2, last2, score_cutoff);
}

template <typename CharT1>
template <typename Sentence2>
double CachedPartialTokenRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedPartialTokenRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -847,8 +840,7 @@ CachedWRatio<Sentence1>::CachedWRatio(InputIt1 first1, InputIt1 last1)

template <typename CharT1>
template <typename InputIt2>
double CachedWRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedWRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff, double) const
{
if (score_cutoff > 100) return 0;

Expand Down Expand Up @@ -887,8 +879,7 @@ double CachedWRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double

template <typename CharT1>
template <typename Sentence2>
double CachedWRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedWRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down Expand Up @@ -919,8 +910,7 @@ double QRatio(const Sentence1& s1, const Sentence2& s2, double score_cutoff)

template <typename CharT1>
template <typename InputIt2>
double CachedQRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedQRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double score_cutoff, double) const
{
auto len2 = std::distance(first2, last2);

Expand All @@ -933,8 +923,7 @@ double CachedQRatio<CharT1>::similarity(InputIt2 first2, InputIt2 last2, double

template <typename CharT1>
template <typename Sentence2>
double CachedQRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff,
[[maybe_unused]] double score_hint) const
double CachedQRatio<CharT1>::similarity(const Sentence2& s2, double score_cutoff, double) const
{
return similarity(detail::to_begin(s2), detail::to_end(s2), score_cutoff);
}
Expand Down

0 comments on commit 2647a66

Please sign in to comment.