lemmeknow
lemmeknow copied to clipboard
use `onig` crate for matching on strings
We can use onig crate instead of regex crate for strings API. We can't fully replace regex crate as onig doesn't provide a way to match on bytes not it compiles for wasm32 ( it might, but that will be lot of work ).
Suggestion
- Use
onigfor matching on strings ( not on wasm32 target ) - Use
regexfor bytes and strings for wasm32
Pros
onigtakes performance from 130ms to 28ms!! It's blazingly fast
Cons
- Variance in performance for matching on strings and bytes for API users, because we have no other choice than using regex crate for bytes
- Extra dependency
Workaround
- We can make a feature called
bytesfor enabling bytes support, that way users can explicitly opt for adding regex crate as dependency and be aware of slower ( comparatively ) performace.
regex vs onig crate benchmark!
