mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 16:24:51 +00:00
Add comment to clearify why the first/last element in preprocess is
skipped
This commit is contained in:
parent
0a016e8fc2
commit
8af1f8ba1a
@ -876,6 +876,8 @@ fn boyerMooreHorspoolPreprocessReverse(pattern: []const u8, table: *[256]usize)
|
||||
}
|
||||
|
||||
var i: usize = pattern.len - 1;
|
||||
// The first item is intentionally ignored and the skip size will be pattern.len.
|
||||
// This is the standard way boyer-moore-horspool is implemented.
|
||||
while (i > 0) : (i -= 1) {
|
||||
table[pattern[i]] = i;
|
||||
}
|
||||
@ -887,6 +889,8 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user