mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Fix start index if @sizeOf(T) > 1
This commit is contained in:
parent
3a6e6bd538
commit
f93498d2d8
@ -930,7 +930,7 @@ pub fn indexOfPos(comptime T: type, haystack: []const T, start_index: usize, nee
|
||||
var skip_table: [256]usize = undefined;
|
||||
boyerMooreHorspoolPreprocess(needle_bytes, skip_table[0..]);
|
||||
|
||||
var i: usize = start_index;
|
||||
var i: usize = start_index * @sizeOf(T);
|
||||
while (i <= haystack_bytes.len - needle_bytes.len) {
|
||||
if (mem.eql(u8, haystack_bytes[i .. i + needle_bytes.len], needle_bytes)) return i;
|
||||
i += skip_table[haystack_bytes[i + needle_bytes.len - 1]];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user