| ... | ... | @@ -1396,6 +1396,7 @@ pub fn indexOf(comptime T: type, haystack: []const T, needle: []const T) ?usize |
| 1396 | 1396 | /// Consider using `lastIndexOf` instead of this, which will automatically use a |
| 1397 | 1397 | /// more sophisticated algorithm on larger inputs. |
| 1398 | 1398 | pub fn lastIndexOfLinear(comptime T: type, haystack: []const T, needle: []const T) ?usize { |
| 1399 | if (needle.len > haystack.len) return null; |
| 1399 | 1400 | var i: usize = haystack.len - needle.len; |
| 1400 | 1401 | while (true) : (i -= 1) { |
| 1401 | 1402 | if (mem.eql(T, haystack[i..][0..needle.len], needle)) return i; |