mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-07 15:33:51 +00:00
reduce loc slightly for levenshteinDistance
This commit is contained in:
parent
2f9c3b7ab9
commit
dc79e7060b
@ -20,11 +20,9 @@
|
||||
// Levenshtein distance function code generated by chatgpt/copilot
|
||||
std::size_t levenshteinDistance(const std::string &s1, const std::string &s2) {
|
||||
std::size_t len1 = s1.size(), len2 = s2.size();
|
||||
if(len1 == 0)
|
||||
return len2;
|
||||
if(len2 == 0)
|
||||
return len1;
|
||||
|
||||
if (len1 == 0 || len2 == 0) {
|
||||
return (std::max)(len1, len2);
|
||||
}
|
||||
std::vector<std::size_t> prev(len2 + 1), curr(len2 + 1);
|
||||
std::iota(prev.begin(), prev.end(), 0); // Fill prev with {0, 1, ..., len2}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user