start some cleanup

This commit is contained in:
maxbachmann 2020-03-31 12:32:53 +02:00
parent 5a759c4fa4
commit d665e3b961
No known key found for this signature in database
GPG Key ID: 60334E83C23820B8
1 changed files with 11 additions and 11 deletions

View File

@ -290,22 +290,22 @@ inline std::size_t levenshtein::distance(std::wstring_view sentence1, std::wstri
size_t temp = *cache_iter; size_t temp = *cache_iter;
*cache_iter += 1; *cache_iter += 1;
for (size_t j = 1; j < cache.size(); ++j) for (const auto& char2 : sentence2) {
{ if (char1 != char2) {
size_t p = *cache_iter; ++temp;
++cache_iter; }
size_t r = *cache_iter;
temp = std::min( temp = std::min({
std::min(r, p) + 1, *cache_iter + 1,
temp + (char1 == sentence2[j - 1] ? 0 : 1) *(++cache_iter) + 1,
); temp
});
std::swap(*cache_iter, temp); std::swap(*cache_iter, temp);
} }
} }
return cache.back(); return cache.back();
} }
template<typename MaxDistanceCalc, typename CharT> template<typename MaxDistanceCalc, typename CharT>
inline auto levenshtein::levenshtein_word_cmp(const CharT &letter_cmp, const string_view_vec<CharT> &words, inline auto levenshtein::levenshtein_word_cmp(const CharT &letter_cmp, const string_view_vec<CharT> &words,
std::vector<std::size_t> &cache, std::size_t current_cache) std::vector<std::size_t> &cache, std::size_t current_cache)