This seems like a really useful optimization. When the regex contains a literal, we can skip over the text until the first letter is found (i.e: calling memchr). Nim's refind and findAll are at least an order of magnitud faster because of this.
It should likely be part of another package that implements fast multi-literal searching foo|bar|baz, using both memchr when there's one or two literals, and a DFA or Aho–Corasick algorithm. It should also support unicode (memchr should search the Rune's last byte).
Then nim-regex can find the literal position and then match backward and forward.
This seems like a really useful optimization. When the regex contains a literal, we can skip over the text until the first letter is found (i.e: calling
memchr
). Nim'sre
find
andfindAll
are at least an order of magnitud faster because of this.It should likely be part of another package that implements fast multi-literal searching
foo|bar|baz
, using bothmemchr
when there's one or two literals, and a DFA or Aho–Corasick algorithm. It should also support unicode (memchr
should search the Rune's last byte).Then nim-regex can find the literal position and then match backward and forward.