| ... | @@ -897,7 +897,9 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void { | ... | @@ -897,7 +897,9 @@ fn boyerMooreHorspoolPreprocess(pattern: []const u8, table: *[256]usize) void { |
| 897 | pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize { | 897 | pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize { |
| 898 | if (needle.len > haystack.len or needle.len == 0) return null; | 898 | if (needle.len > haystack.len or needle.len == 0) return null; |
| 899 | | 899 | |
| 900 | if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2) | 900 | // byte comparison with float doesn't work because +0.0 and -0.0 and considered |
| | 901 | // equal but their byte representations are not equal. |
| | 902 | if (@typeInfo(T) == .Float or haystack.len < 32 or needle.len <= 2) |
| 901 | return lastIndexOfLinear(T, haystack, needle); | 903 | return lastIndexOfLinear(T, haystack, needle); |
| 902 | | 904 | |
| 903 | const haystack_bytes = sliceAsBytes(haystack); | 905 | const haystack_bytes = sliceAsBytes(haystack); |
| ... | @@ -921,7 +923,9 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us | ... | @@ -921,7 +923,9 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us |
| 921 | pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize { | 923 | pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, needle: []const T) ?usize { |
| 922 | if (needle.len > haystack.len or needle.len == 0) return null; | 924 | if (needle.len > haystack.len or needle.len == 0) return null; |
| 923 | | 925 | |
| 924 | if (!isValidAlign(T.bit_count) or haystack.len < 32 or needle.len <= 2) | 926 | // byte comparison with float doesn't work because +0.0 and -0.0 and considered |
| | 927 | // equal but their byte representations are not equal. |
| | 928 | if (@typeInfo(T) == .Float or haystack.len < 32 or needle.len <= 2) |
| 925 | return indexOfPosLinear(T, haystack, start_index, needle); | 929 | return indexOfPosLinear(T, haystack, start_index, needle); |
| 926 | | 930 | |
| 927 | const haystack_bytes = sliceAsBytes(haystack); | 931 | const haystack_bytes = sliceAsBytes(haystack); |