fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void pattern: []const u8table: *[256]usize1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void {
for (table) |*c| {
c.* = pattern.len;
}
var i: usize = 0;
// The last item is intentionally ignored and the skip size will be pattern.len.
// This is the standard way Boyer-Moore-Horspool is implemented.
while (i < pattern.len - 1) : (i += 1) {
table[pattern[i]] = pattern.len - 1 - i;
}
}