diff options
author | Abseil Team <absl-team@google.com> | 2022-10-27 01:10:59 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-27 01:11:42 -0700 |
commit | 1b6a9e95a704ff947438ae8b829072c78a0f0fdc (patch) | |
tree | e06c37b209c33b4e722cd7eff558ff08432f7042 /absl | |
parent | bc097314fe5ba91e7f358159f84d7b9477502f75 (diff) |
Return uint8_t from CappedDamerauLevenshteinDistance.
PiperOrigin-RevId: 484181180
Change-Id: I00206c1506a25dca5555261d6500c1e54368a368
Diffstat (limited to 'absl')
-rw-r--r-- | absl/strings/internal/damerau_levenshtein_distance.cc | 6 | ||||
-rw-r--r-- | absl/strings/internal/damerau_levenshtein_distance.h | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/absl/strings/internal/damerau_levenshtein_distance.cc b/absl/strings/internal/damerau_levenshtein_distance.cc index 7cc23acd..a084568f 100644 --- a/absl/strings/internal/damerau_levenshtein_distance.cc +++ b/absl/strings/internal/damerau_levenshtein_distance.cc @@ -31,8 +31,8 @@ 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, - absl::string_view s2, uint8_t cutoff) { +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); const uint8_t cutoff_plus_1 = static_cast<uint8_t>(_cutoff + 1); @@ -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 = diff --git a/absl/strings/internal/damerau_levenshtein_distance.h b/absl/strings/internal/damerau_levenshtein_distance.h index b9bb6fe1..1a968425 100644 --- a/absl/strings/internal/damerau_levenshtein_distance.h +++ b/absl/strings/internal/damerau_levenshtein_distance.h @@ -25,8 +25,8 @@ 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, - absl::string_view s2, uint8_t cutoff); +uint8_t CappedDamerauLevenshteinDistance(absl::string_view s1, + absl::string_view s2, uint8_t cutoff); } // namespace strings_internal ABSL_NAMESPACE_END |