Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

findIgnoreCasePos

Public Function
std.ascii.findIgnoreCasePos
pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize

Finds needle in haystack, ignoring case, starting at start_index. Uses Boyer-Moore-Horspool algorithm on large inputs; findIgnoreCasePosLinear on small inputs.

Params

  • haystack: []const u8
  • start_index: usize
  • needle: []const u8

File

ascii.zig:388
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
pub fn findIgnoreCasePos(haystack: []const u8, start_index: usize, needle: []const u8) ?usize {
    if (needle.len > haystack.len) return null;
    if (needle.len == 0) return start_index;

    if (haystack.len < 52 or needle.len <= 4)
        return findIgnoreCasePosLinear(haystack, start_index, needle);

    var skip_table: [256]usize = undefined;
    boyerMooreHorspoolPreprocessIgnoreCase(needle, skip_table[0..]);

    var i: usize = start_index;
    while (i <= haystack.len - needle.len) {
        if (eqlIgnoreCase(haystack[i .. i + needle.len], needle)) return i;
        i += skip_table[toLower(haystack[i + needle.len - 1])];
    }

    return null;
}