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