| ... | @@ -53,17 +53,17 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons | ... | @@ -53,17 +53,17 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons |
| 53 | const array = try alloc.alloc(usize, ll); | 53 | const array = try alloc.alloc(usize, ll); |
| 54 | defer alloc.free(array); | 54 | defer alloc.free(array); |
| 55 | | 55 | |
| 56 | for (range(ll)) |_, i| { | 56 | for (range(ll), 0..) |_, i| { |
| 57 | charCodeCache[i] = left[start + i]; | 57 | charCodeCache[i] = left[start + i]; |
| 58 | array[i] = i + 1; | 58 | array[i] = i + 1; |
| 59 | } | 59 | } |
| 60 | | 60 | |
| 61 | for (range(rl)) |_, j| { | 61 | for (range(rl), 0..) |_, j| { |
| 62 | const bCharCode = right[start + j]; | 62 | const bCharCode = right[start + j]; |
| 63 | var temp = j; | 63 | var temp = j; |
| 64 | result = j + 1; | 64 | result = j + 1; |
| 65 | | 65 | |
| 66 | for (range(ll)) |_, i| { | 66 | for (range(ll), 0..) |_, i| { |
| 67 | const temp2 = if (bCharCode == charCodeCache[i]) temp else temp + 1; | 67 | const temp2 = if (bCharCode == charCodeCache[i]) temp else temp + 1; |
| 68 | temp = array[i]; | 68 | temp = array[i]; |
| 69 | array[i] = if (temp > result) (if (temp2 > result) result + 1 else temp2) else (if (temp2 > temp) temp + 1 else temp2); | 69 | array[i] = if (temp > result) (if (temp2 > result) result + 1 else temp2) else (if (temp2 > temp) temp + 1 else temp2); |