Skip to content

Commit f651666

Browse files
committed
fix compiler warning
1 parent 575c1fa commit f651666

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

extras/rapidfuzz_amalgamated.hpp

Lines changed: 12 additions & 3 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: 2024-10-24 14:15:39.050296
4+
// Generated: 2024-10-24 15:27:27.715931
55
// ----------------------------------------------------------
66
// This file is an amalgamation of multiple different files.
77
// You probably shouldn't edit it directly.
@@ -1594,6 +1594,15 @@ static inline size_t abs_diff(size_t a, size_t b)
15941594
return a > b ? a - b : b - a;
15951595
}
15961596

1597+
template <typename TO, typename FROM>
1598+
TO opt_static_cast(const FROM& value)
1599+
{
1600+
if constexpr (std::is_same_v<TO, FROM>)
1601+
return value;
1602+
else
1603+
return static_cast<TO>(value);
1604+
}
1605+
15971606
/**
15981607
* @defgroup Common Common
15991608
* Common utilities shared among multiple functions
@@ -7396,8 +7405,8 @@ auto levenshtein_hyrroe2003_block(const BlockPatternMatchVector& PM, const Range
73967405
vecs[last_block].VN = 0;
73977406

73987407
size_t chars_in_block = (last_block + 1 == words) ? ((s1.size() - 1) % word_size + 1) : 64;
7399-
scores[last_block] = scores[last_block - 1] + chars_in_block - static_cast<size_t>(HP_carry) +
7400-
static_cast<size_t>(HN_carry);
7408+
scores[last_block] = scores[last_block - 1] + chars_in_block -
7409+
opt_static_cast<size_t>(HP_carry) + opt_static_cast<size_t>(HN_carry);
74017410
// todo probably wrong types
74027411
scores[last_block] = static_cast<size_t>(static_cast<ptrdiff_t>(scores[last_block]) +
74037412
advance_block(last_block));

rapidfuzz/details/common.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ static inline size_t abs_diff(size_t a, size_t b)
3333
return a > b ? a - b : b - a;
3434
}
3535

36+
template<typename TO, typename FROM>
37+
TO opt_static_cast(const FROM &value)
38+
{
39+
if constexpr (std::is_same_v<TO, FROM>)
40+
return value;
41+
else
42+
return static_cast<TO>(value);
43+
}
44+
3645
/**
3746
* @defgroup Common Common
3847
* Common utilities shared among multiple functions

rapidfuzz/distance/Levenshtein_impl.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ size_t levenshtein_hyrroe2003_small_band(const BlockPatternMatchVector& PM, cons
471471
}
472472

473473
template <bool RecordMatrix, typename InputIt1, typename InputIt2>
474-
auto levenshtein_hyrroe2003_small_band(const Range<InputIt1>& s1, const Range<InputIt2>& s2, size_t max)
475-
-> LevenshteinResult<RecordMatrix, false>
474+
auto levenshtein_hyrroe2003_small_band(const Range<InputIt1>& s1, const Range<InputIt2>& s2,
475+
size_t max) -> LevenshteinResult<RecordMatrix, false>
476476
{
477477
assert(max <= s1.size());
478478
assert(max <= s2.size());
@@ -727,7 +727,8 @@ auto levenshtein_hyrroe2003_block(const BlockPatternMatchVector& PM, const Range
727727
vecs[last_block].VN = 0;
728728

729729
size_t chars_in_block = (last_block + 1 == words) ? ((s1.size() - 1) % word_size + 1) : 64;
730-
scores[last_block] = scores[last_block - 1] + chars_in_block - static_cast<size_t>(HP_carry) + static_cast<size_t>(HN_carry);
730+
scores[last_block] = scores[last_block - 1] + chars_in_block -
731+
opt_static_cast<size_t>(HP_carry) + opt_static_cast<size_t>(HN_carry);
731732
// todo probably wrong types
732733
scores[last_block] = static_cast<size_t>(static_cast<ptrdiff_t>(scores[last_block]) +
733734
advance_block(last_block));

0 commit comments

Comments
 (0)