| ... | @@ -888,13 +888,13 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: []usize) void { | ... | @@ -888,13 +888,13 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: []usize) void { |
| 888 | /// To start looking at a different index, slice the haystack first. | 888 | /// To start looking at a different index, slice the haystack first. |
| 889 | // Reverse boyer-moore-horspool algorithm | 889 | // Reverse boyer-moore-horspool algorithm |
| 890 | pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize { | 890 | pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize { |
| 891 | if (haystack.len < 32 or needle.len <= 2) | 891 | if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2) |
| 892 | return lastIndexOfNaive(T, haystack, needle); | 892 | return lastIndexOfNaive(T, haystack, needle); |
| 893 | | 893 | |
| 894 | if (needle.len > haystack.len or needle.len == 0) return null; | 894 | if (needle.len > haystack.len or needle.len == 0) return null; |
| 895 | | 895 | |
| 896 | const haystackU8 = @bitCast([]const u8, haystack); | 896 | const haystackU8 = sliceAsBytes(haystack); |
| 897 | const needleU8 = @bitCast([]const u8, needle); | 897 | const needleU8 = sliceAsBytes(needle); |
| 898 | | 898 | |
| 899 | var table: [256]usize = undefined; | 899 | var table: [256]usize = undefined; |
| 900 | boyerMooreHorspoolPreprocess(needleU8, table[0..]); | 900 | boyerMooreHorspoolPreprocess(needleU8, table[0..]); |
| ... | @@ -911,13 +911,13 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us | ... | @@ -911,13 +911,13 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us |
| 911 | | 911 | |
| 912 | // Boyer-moore-horspool algorithm | 912 | // Boyer-moore-horspool algorithm |
| 913 | pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize { | 913 | pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize { |
| 914 | if (haystack.len < 32 or needle.len <= 2) | 914 | if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2) |
| 915 | return indexOfPosNaive(T, haystack, start_index, needle); | 915 | return indexOfPosNaive(T, haystack, start_index, needle); |
| 916 | | 916 | |
| 917 | if (needle.len > haystack.len or needle.len == 0) return null; | 917 | if (needle.len > haystack.len or needle.len == 0) return null; |
| 918 | | 918 | |
| 919 | const haystackU8 = @bitCast([]const u8, haystack); | 919 | const haystackU8 = sliceAsBytes(haystack); |
| 920 | const needleU8 = @bitCast([]const u8, needle); | 920 | const needleU8 = sliceAsBytes(needle); |
| 921 | | 921 | |
| 922 | var table: [256]usize = undefined; | 922 | var table: [256]usize = undefined; |
| 923 | boyerMooreHorspoolPreprocess(needleU8, table[0..]); | 923 | boyerMooreHorspoolPreprocess(needleU8, table[0..]); |