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