Skip to content

Commit bed2d6c

Browse files
committed
fix compiler warnings
1 parent 87caa3a commit bed2d6c

2 files changed

Lines changed: 38 additions & 38 deletions

File tree

extras/rapidfuzz_amalgamated.hpp

Lines changed: 23 additions & 23 deletions
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: 2023-10-31 10:37:34.774579
4+
// Generated: 2023-10-31 11:09:46.332642
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -5717,7 +5717,7 @@ static inline auto jaro_similarity_prepare_bound_short_s2(const VecType* s1_leng
57175717

57185718
static constexpr size_t alignment = native_simd<VecType>::alignment;
57195719
static constexpr size_t vec_width = native_simd<VecType>::size;
5720-
assert(static_cast<size_t>(s2.size()) > sizeof(VecType) * 8);
5720+
assert(static_cast<size_t>(s2.size()) <= sizeof(VecType) * 8);
57215721

57225722
JaroSimilaritySimdBounds<native_simd<VecType>> bounds;
57235723

@@ -5769,7 +5769,7 @@ static inline auto jaro_similarity_prepare_bound_short_s2(const VecType* s1_leng
57695769
bounds.boundMask = native_simd<VecType>(reinterpret_cast<uint64_t*>(boundMask_.data()));
57705770
# endif
57715771

5772-
int64_t lastRelevantChar = maxLen + bounds.maxBound;
5772+
int64_t lastRelevantChar = static_cast<int64_t>(maxLen) + bounds.maxBound;
57735773
if (s2.size() > lastRelevantChar) s2.remove_suffix(s2.size() - lastRelevantChar);
57745774

57755775
return bounds;
@@ -5784,7 +5784,6 @@ static inline auto jaro_similarity_prepare_bound_long_s2(const VecType* s1_lengt
57845784
using namespace simd_sse2;
57855785
# endif
57865786

5787-
static constexpr size_t alignment = native_simd<VecType>::alignment;
57885787
static constexpr size_t vec_width = native_simd<VecType>::size;
57895788
assert(static_cast<size_t>(s2.size()) > sizeof(VecType) * 8);
57905789

@@ -5800,17 +5799,16 @@ static inline auto jaro_similarity_prepare_bound_long_s2(const VecType* s1_lengt
58005799
bounds.boundMaskSize = native_simd<VecType>(bit_mask_lsb<VecType>(static_cast<int>(2 * bounds.maxBound)));
58015800
bounds.boundMask = native_simd<VecType>(bit_mask_lsb<VecType>(static_cast<int>(bounds.maxBound + 1)));
58025801

5803-
int64_t lastRelevantChar = maxLen + bounds.maxBound;
5802+
int64_t lastRelevantChar = static_cast<int64_t>(maxLen) + bounds.maxBound;
58045803
if (s2.size() > lastRelevantChar) s2.remove_suffix(s2.size() - lastRelevantChar);
58055804

58065805
return bounds;
58075806
}
58085807

58095808
template <typename VecType, typename InputIt, int _lto_hack = RAPIDFUZZ_LTO_HACK>
5810-
static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
5811-
const detail::BlockPatternMatchVector& block,
5812-
VecType* s1_lengths, size_t s1_lengths_size,
5813-
Range<InputIt> s2, double score_cutoff) noexcept
5809+
static inline void
5810+
jaro_similarity_simd_long_s2(Range<double*> scores, const detail::BlockPatternMatchVector& block,
5811+
VecType* s1_lengths, Range<InputIt> s2, double score_cutoff) noexcept
58145812
{
58155813
# ifdef RAPIDFUZZ_AVX2
58165814
using namespace simd_avx2;
@@ -5828,14 +5826,15 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
58285826
native_simd<VecType> one(1);
58295827
size_t result_index = 0;
58305828

5829+
size_t s2_block_count = static_cast<size_t>(detail::ceil_div(s2.size(), sizeof(VecType) * 8));
58315830
std::vector<native_simd<VecType>> T_flag;
5832-
T_flag.resize(detail::ceil_div(s2.size(), sizeof(VecType) * 8));
5831+
T_flag.resize(s2_block_count);
58335832

58345833
std::vector<native_simd<VecType>> counter;
5835-
counter.resize(detail::ceil_div(s2.size(), sizeof(VecType) * 8));
5834+
counter.resize(s2_block_count);
58365835

58375836
std::vector<std::array<VecType, vec_width>> T_flags;
5838-
T_flags.resize(detail::ceil_div(s2.size(), sizeof(VecType) * 8));
5837+
T_flags.resize(s2_block_count);
58395838

58405839
for (size_t cur_vec = 0; cur_vec < block.size(); cur_vec += vecs) {
58415840
auto s2_cur = s2;
@@ -5861,7 +5860,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
58615860
native_simd<VecType> PM_j = andnot(X & bounds.boundMask, P_flag);
58625861

58635862
P_flag |= blsi(PM_j);
5864-
auto T_word_index = j / (sizeof(VecType) * 8);
5863+
size_t T_word_index = static_cast<size_t>(j) / (sizeof(VecType) * 8);
58655864
T_flag[T_word_index] |= andnot(counter[T_word_index], (PM_j == zero));
58665865

58675866
counter[T_word_index] = counter[T_word_index] << 1;
@@ -5875,7 +5874,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
58755874
native_simd<VecType> PM_j = andnot(X & bounds.boundMask, P_flag);
58765875

58775876
P_flag |= blsi(PM_j);
5878-
auto T_word_index = j / (sizeof(VecType) * 8);
5877+
size_t T_word_index = static_cast<size_t>(j) / (sizeof(VecType) * 8);
58795878
T_flag[T_word_index] |= andnot(counter[T_word_index], (PM_j == zero));
58805879

58815880
counter[T_word_index] = counter[T_word_index] << 1;
@@ -5886,7 +5885,8 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
58865885
alignas(alignment) std::array<VecType, vec_width> P_flags;
58875886
P_flag.store(P_flags.data());
58885887

5889-
for (size_t i = 0; i < detail::ceil_div(s2_cur.size(), sizeof(VecType) * 8); ++i) {
5888+
for (size_t i = 0; i < static_cast<size_t>(detail::ceil_div(s2_cur.size(), sizeof(VecType) * 8)); ++i)
5889+
{
58905890
alignas(alignment) std::array<VecType, vec_width> T_flags_;
58915891
T_flag[i].store(T_flags_.data());
58925892
T_flags[i] = T_flags_;
@@ -5920,8 +5920,9 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
59205920

59215921
VecType PatternFlagMask = blsi(P_flag_cur);
59225922

5923-
uint64_t PM_j = block.get(
5924-
cur_block, s2[countr_zero(T_flag_cur) + T_word_index * sizeof(VecType) * 8]);
5923+
uint64_t PM_j =
5924+
block.get(cur_block, s2[countr_zero(T_flag_cur) +
5925+
static_cast<ptrdiff_t>(T_word_index * sizeof(VecType) * 8)]);
59255926
Transpositions += !(PM_j & (static_cast<uint64_t>(PatternFlagMask) << offset));
59265927

59275928
T_flag_cur = blsr(T_flag_cur);
@@ -5939,10 +5940,9 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores,
59395940
}
59405941

59415942
template <typename VecType, typename InputIt, int _lto_hack = RAPIDFUZZ_LTO_HACK>
5942-
static inline void jaro_similarity_simd_short_s2(Range<double*> scores,
5943-
const detail::BlockPatternMatchVector& block,
5944-
VecType* s1_lengths, size_t s1_lengths_size,
5945-
Range<InputIt> s2, double score_cutoff) noexcept
5943+
static inline void
5944+
jaro_similarity_simd_short_s2(Range<double*> scores, const detail::BlockPatternMatchVector& block,
5945+
VecType* s1_lengths, Range<InputIt> s2, double score_cutoff) noexcept
59465946
{
59475947
# ifdef RAPIDFUZZ_AVX2
59485948
using namespace simd_avx2;
@@ -6061,9 +6061,9 @@ static inline void jaro_similarity_simd(Range<double*> scores, const detail::Blo
60616061
}
60626062

60636063
if (static_cast<size_t>(s2.size()) > sizeof(VecType) * 8)
6064-
return jaro_similarity_simd_long_s2(scores, block, s1_lengths, s1_lengths_size, s2, score_cutoff);
6064+
return jaro_similarity_simd_long_s2(scores, block, s1_lengths, s2, score_cutoff);
60656065
else
6066-
return jaro_similarity_simd_short_s2(scores, block, s1_lengths, s1_lengths_size, s2, score_cutoff);
6066+
return jaro_similarity_simd_short_s2(scores, block, s1_lengths, s2, score_cutoff);
60676067
}
60686068

60696069
#endif /* RAPIDFUZZ_SIMD */

rapidfuzz/distance/Jaro_impl.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static inline auto jaro_similarity_prepare_bound_short_s2(const VecType* s1_leng
476476

477477
static constexpr size_t alignment = native_simd<VecType>::alignment;
478478
static constexpr size_t vec_width = native_simd<VecType>::size;
479-
assert(static_cast<size_t>(s2.size()) > sizeof(VecType)*8);
479+
assert(static_cast<size_t>(s2.size()) <= sizeof(VecType)*8);
480480

481481
JaroSimilaritySimdBounds<native_simd<VecType>> bounds;
482482

@@ -530,7 +530,7 @@ static inline auto jaro_similarity_prepare_bound_short_s2(const VecType* s1_leng
530530
bounds.boundMask = native_simd<VecType>(reinterpret_cast<uint64_t*>(boundMask_.data()));
531531
#endif
532532

533-
int64_t lastRelevantChar = maxLen + bounds.maxBound;
533+
int64_t lastRelevantChar = static_cast<int64_t>(maxLen) + bounds.maxBound;
534534
if (s2.size() > lastRelevantChar) s2.remove_suffix(s2.size() - lastRelevantChar);
535535

536536
return bounds;
@@ -545,7 +545,6 @@ static inline auto jaro_similarity_prepare_bound_long_s2(const VecType* s1_lengt
545545
using namespace simd_sse2;
546546
# endif
547547

548-
static constexpr size_t alignment = native_simd<VecType>::alignment;
549548
static constexpr size_t vec_width = native_simd<VecType>::size;
550549
assert(static_cast<size_t>(s2.size()) > sizeof(VecType)*8);
551550

@@ -562,15 +561,15 @@ static inline auto jaro_similarity_prepare_bound_long_s2(const VecType* s1_lengt
562561
bounds.boundMaskSize = native_simd<VecType>(bit_mask_lsb<VecType>(static_cast<int>(2 * bounds.maxBound)));
563562
bounds.boundMask = native_simd<VecType>(bit_mask_lsb<VecType>(static_cast<int>(bounds.maxBound + 1)));
564563

565-
int64_t lastRelevantChar = maxLen + bounds.maxBound;
564+
int64_t lastRelevantChar = static_cast<int64_t>(maxLen) + bounds.maxBound;
566565
if (s2.size() > lastRelevantChar) s2.remove_suffix(s2.size() - lastRelevantChar);
567566

568567
return bounds;
569568
}
570569

571570
template <typename VecType, typename InputIt, int _lto_hack = RAPIDFUZZ_LTO_HACK>
572571
static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const detail::BlockPatternMatchVector& block,
573-
VecType* s1_lengths, size_t s1_lengths_size,
572+
VecType* s1_lengths,
574573
Range<InputIt> s2,
575574
double score_cutoff) noexcept
576575
{
@@ -590,14 +589,15 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
590589
native_simd<VecType> one(1);
591590
size_t result_index = 0;
592591

592+
size_t s2_block_count = static_cast<size_t>(detail::ceil_div(s2.size(), sizeof(VecType)*8));
593593
std::vector<native_simd<VecType>> T_flag;
594-
T_flag.resize(detail::ceil_div(s2.size(), sizeof(VecType)*8));
594+
T_flag.resize(s2_block_count);
595595

596596
std::vector<native_simd<VecType>> counter;
597-
counter.resize(detail::ceil_div(s2.size(), sizeof(VecType)*8));
597+
counter.resize(s2_block_count);
598598

599599
std::vector<std::array<VecType, vec_width>> T_flags;
600-
T_flags.resize(detail::ceil_div(s2.size(), sizeof(VecType)*8));
600+
T_flags.resize(s2_block_count);
601601

602602
for (size_t cur_vec = 0; cur_vec < block.size(); cur_vec += vecs) {
603603
auto s2_cur = s2;
@@ -622,7 +622,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
622622
native_simd<VecType> PM_j = andnot(X & bounds.boundMask, P_flag);
623623

624624
P_flag |= blsi(PM_j);
625-
auto T_word_index = j / (sizeof(VecType)*8);
625+
size_t T_word_index = static_cast<size_t>(j) / (sizeof(VecType)*8);
626626
T_flag[T_word_index] |= andnot(counter[T_word_index], (PM_j == zero));
627627

628628
counter[T_word_index] = counter[T_word_index] << 1;
@@ -637,7 +637,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
637637
native_simd<VecType> PM_j = andnot(X & bounds.boundMask, P_flag);
638638

639639
P_flag |= blsi(PM_j);
640-
auto T_word_index = j / (sizeof(VecType)*8);
640+
size_t T_word_index = static_cast<size_t>(j) / (sizeof(VecType)*8);
641641
T_flag[T_word_index] |= andnot(counter[T_word_index], (PM_j == zero));
642642

643643
counter[T_word_index] = counter[T_word_index] << 1;
@@ -648,7 +648,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
648648
alignas(alignment) std::array<VecType, vec_width> P_flags;
649649
P_flag.store(P_flags.data());
650650

651-
for(size_t i = 0; i < detail::ceil_div(s2_cur.size(), sizeof(VecType)*8); ++i)
651+
for(size_t i = 0; i < static_cast<size_t>(detail::ceil_div(s2_cur.size(), sizeof(VecType)*8)); ++i)
652652
{
653653
alignas(alignment) std::array<VecType, vec_width> T_flags_;
654654
T_flag[i].store(T_flags_.data());
@@ -683,7 +683,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
683683

684684
VecType PatternFlagMask = blsi(P_flag_cur);
685685

686-
uint64_t PM_j = block.get(cur_block, s2[countr_zero(T_flag_cur) + T_word_index * sizeof(VecType) * 8]);
686+
uint64_t PM_j = block.get(cur_block, s2[countr_zero(T_flag_cur) + static_cast<ptrdiff_t>(T_word_index * sizeof(VecType) * 8)]);
687687
Transpositions += !(PM_j & (static_cast<uint64_t>(PatternFlagMask) << offset));
688688

689689
T_flag_cur = blsr(T_flag_cur);
@@ -702,7 +702,7 @@ static inline void jaro_similarity_simd_long_s2(Range<double*> scores, const det
702702

703703
template <typename VecType, typename InputIt, int _lto_hack = RAPIDFUZZ_LTO_HACK>
704704
static inline void jaro_similarity_simd_short_s2(Range<double*> scores, const detail::BlockPatternMatchVector& block,
705-
VecType* s1_lengths, size_t s1_lengths_size,
705+
VecType* s1_lengths,
706706
Range<InputIt> s2,
707707
double score_cutoff) noexcept
708708
{
@@ -824,9 +824,9 @@ static inline void jaro_similarity_simd(Range<double*> scores, const detail::Blo
824824
}
825825

826826
if (static_cast<size_t>(s2.size()) > sizeof(VecType)*8)
827-
return jaro_similarity_simd_long_s2(scores, block, s1_lengths, s1_lengths_size, s2, score_cutoff);
827+
return jaro_similarity_simd_long_s2(scores, block, s1_lengths, s2, score_cutoff);
828828
else
829-
return jaro_similarity_simd_short_s2(scores, block, s1_lengths, s1_lengths_size, s2, score_cutoff);
829+
return jaro_similarity_simd_short_s2(scores, block, s1_lengths, s2, score_cutoff);
830830
}
831831

832832
#endif /* RAPIDFUZZ_SIMD */

0 commit comments

Comments
 (0)