nitely / nim-regex

Pure Nim regex engine. Guarantees linear time matching
https://nitely.github.io/nim-regex/
MIT License
225 stars 20 forks source link

Literals substring optimization #130

Closed nitely closed 9 months ago

nitely commented 9 months ago

This reuses the lits opt to find the lit delimiter, then grabs the surrounding lits, and tries to find the literal sub-string. It should usually be faster when memmem is supported. Otherwise it depends on how many candidates to memchr there are in the input text vs lit substring candidates, so it's input text dependent.

I also added support for unicode lit delimiters.

Added some benchs where it's ~6x faster than before, and 3x faster than PCRE.

I think the idea is good, but the code can be simpler.