| ... | @@ -907,7 +907,7 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us | ... | @@ -907,7 +907,7 @@ pub fn lastIndexOf(comptime T: type, haystack: []const T, needle: []const T) ?us |
| 907 | if (needle.len > haystack.len) return null; | 907 | if (needle.len > haystack.len) return null; |
| 908 | if (needle.len == 0) return haystack.len; | 908 | if (needle.len == 0) return haystack.len; |
| 909 | | 909 | |
| 910 | if (!meta.trait.hasUniqueRepresentation(T) or haystack.len < 32 or needle.len <= 2) | 910 | if (!meta.trait.hasUniqueRepresentation(T) or haystack.len < 52 or needle.len <= 4) |
| 911 | return lastIndexOfLinear(T, haystack, needle); | 911 | return lastIndexOfLinear(T, haystack, needle); |
| 912 | | 912 | |
| 913 | const haystack_bytes = sliceAsBytes(haystack); | 913 | const haystack_bytes = sliceAsBytes(haystack); |
| ... | @@ -951,10 +951,10 @@ pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, nee | ... | @@ -951,10 +951,10 @@ pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, nee |
| 951 | } | 951 | } |
| 952 | | 952 | |
| 953 | test "mem.indexOf" { | 953 | test "mem.indexOf" { |
| 954 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten", "three four").? == 8); | 954 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8); |
| 955 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "three four").? == 8); | 955 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "three four").? == 8); |
| 956 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten", "two two") == null); | 956 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null); |
| 957 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "two two") == null); | 957 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten eleven", "two two") == null); |
| 958 | | 958 | |
| 959 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten", "").? == 0); | 959 | testing.expect(indexOf(u8, "one two three four five six seven eight nine ten", "").? == 0); |
| 960 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48); | 960 | testing.expect(lastIndexOf(u8, "one two three four five six seven eight nine ten", "").? == 48); |