authorgravatar for dec05eba@protonmail.comdec05eba <dec05eba@protonmail.com> 2020-09-05 21:15:44+02:00
committergravatar for dec05eba@protonmail.comdec05eba <dec05eba@protonmail.com> 2020-09-05 21:15:44+02:00
log8af1f8ba1ad43a750e0040ac845b331241ead329
tree722d56308ce3ae143c110a666b25bd17ff710481
parent0a016e8fc29467e48cfc04b1ee829bbd254b2d6d

Add comment to clearify why the first/last element in preprocess is

skipped

1 files changed, 4 insertions(+), 0 deletions(-)

lib/std/mem.zig+4
......@@ -876,6 +876,8 @@ fn boyerMooreHorspoolPreprocessReverse(pattern: []const u8, table: *[256]usize)
876876 }
877877
878878 var i: usize = pattern.len - 1;
879 // The first item is intentionally ignored and the skip size will be pattern.len.
880 // This is the standard way boyer-moore-horspool is implemented.
879881 while (i > 0) : (i -= 1) {
880882 table[pattern[i]] = i;
881883 }
......@@ -887,6 +889,8 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void {
887889 }
888890
889891 var i: usize = 0;
892 // The last item is intentionally ignored and the skip size will be pattern.len.
893 // This is the standard way boyer-moore-horspool is implemented.
890894 while (i < pattern.len - 1) : (i += 1) {
891895 table[pattern[i]] = pattern.len - 1 - i;
892896 }