memchr_wide

memchr_wide

Mojo function 🡭

memchr_wide

 
fn memchr_wide(haystack: Span[SIMD[uint8, 1], origin], chr: SIMD[uint8, 1], start: Int = 0) -> Int

Function to find the next occurrence of character. This function does more unrolling and will be faster if the search if over longer distances. If in doubt use memchr.

from testing import assert_equal
from extramojo.bstr.memchr import memchr_wide

assert_equal(memchr_wide("enlivened,unleavened,Arnulfo's,Unilever's,unloved|Anouilh,analogue,analogy".as_bytes(), ord("|")), 49)

Args:

  • haystack (Span): The bytes to search for the chr.
  • chr (SIMD): The byte to search for.
  • start (Int): The starting point to begin the search in haystack.

Returns:

Int: The index of the found character, or -1 if not found.