Message393006
I had a chance to read Python/suggestion.c and I can notice that we use the static declared size of the array.
Since we live in the C99 era and the CPython codebase already uses C99(struct initialization is a good example), how about using the C99 feature if possible.
We should care about stack overflow from the big input but with the expected very small input size it will be okay to use.
- static size_t buffer[MAX_STRING_SIZE];
-
// Both strings are the same (by identity)
if (a == b) {
return 0;
@@ -68,6 +66,8 @@ levenshtein_distance(const char *a, size_t a_size,
size_t t_size = a_size; a_size = b_size; b_size = t_size;
}
+ size_t buffer[a_size];
+
// quick fail when a match is impossible.
if ((b_size - a_size) * MOVE_COST > max_cost) {
return max_cost + 1 |
|
Date |
User |
Action |
Args |
2021-05-05 12:10:58 | corona10 | set | recipients:
+ corona10, vstinner, pablogsal |
2021-05-05 12:10:58 | corona10 | set | messageid: <1620216658.8.0.390756797773.issue44049@roundup.psfhosted.org> |
2021-05-05 12:10:58 | corona10 | link | issue44049 messages |
2021-05-05 12:10:58 | corona10 | create | |
|