Commit 1b6a9e95 by Abseil Team Committed by Copybara-Service

Return uint8_t from CappedDamerauLevenshteinDistance.

PiperOrigin-RevId: 484181180
Change-Id: I00206c1506a25dca5555261d6500c1e54368a368
parent bc097314
......@@ -31,7 +31,7 @@ namespace strings_internal {
// detected.
// When the distance is larger than cutoff, or one of the strings has more
// than MAX_SIZE=100 characters, the code returns min(MAX_SIZE, cutoff) + 1.
size_t CappedDamerauLevenshteinDistance(absl::string_view s1,
uint8_t CappedDamerauLevenshteinDistance(absl::string_view s1,
absl::string_view s2, uint8_t cutoff) {
const uint8_t MAX_SIZE = 100;
const uint8_t _cutoff = std::min(MAX_SIZE, cutoff);
......@@ -42,7 +42,7 @@ size_t CappedDamerauLevenshteinDistance(absl::string_view s1,
return cutoff_plus_1;
if (s1.empty())
return std::min(static_cast<size_t>(cutoff_plus_1), s2.size());
return static_cast<uint8_t>(s2.size());
// Lower diagonal bound: y = x - lower_diag
const uint8_t lower_diag =
......
......@@ -25,7 +25,7 @@ ABSL_NAMESPACE_BEGIN
namespace strings_internal {
// Calculate DamerauLevenshtein distance between two strings.
// When the distance is larger than cutoff, the code just returns cutoff + 1.
size_t CappedDamerauLevenshteinDistance(absl::string_view s1,
uint8_t CappedDamerauLevenshteinDistance(absl::string_view s1,
absl::string_view s2, uint8_t cutoff);
} // namespace strings_internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment