| ... | @@ -14,7 +14,7 @@ const std = @import("std"); | ... | @@ -14,7 +14,7 @@ const std = @import("std"); |
| 14 | // ); | 14 | // ); |
| 15 | // } | 15 | // } |
| 16 | | 16 | |
| 17 | pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize { | 17 | pub fn leven(comptime T: type, backing_alloc: std.mem.Allocator, a: []const T, b: []const T, max: ?usize) !usize { |
| 18 | if (std.mem.eql(T, a, b)) return 0; | 18 | if (std.mem.eql(T, a, b)) return 0; |
| 19 | | 19 | |
| 20 | var left = a; | 20 | var left = a; |
| ... | @@ -46,6 +46,9 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons | ... | @@ -46,6 +46,9 @@ pub fn leven(comptime T: type, alloc: std.mem.Allocator, a: []const T, b: []cons |
| 46 | | 46 | |
| 47 | var result: usize = 0; | 47 | var result: usize = 0; |
| 48 | | 48 | |
| | 49 | var sfa = std.heap.stackFallback(4096, backing_alloc); |
| | 50 | const alloc = sfa.get(); |
| | 51 | |
| 49 | const charCodeCache = try alloc.alloc(T, ll); | 52 | const charCodeCache = try alloc.alloc(T, ll); |
| 50 | defer alloc.free(charCodeCache); | 53 | defer alloc.free(charCodeCache); |
| 51 | | 54 | |