Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use onig crate for matching on strings #10

Open
swanandx opened this issue Aug 16, 2022 · 0 comments
Open

use onig crate for matching on strings #10

swanandx opened this issue Aug 16, 2022 · 0 comments

Comments

@swanandx
Copy link
Owner

swanandx commented Aug 16, 2022

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 onig for matching on strings ( not on wasm32 target )
  • Use regex for bytes and strings for wasm32

Pros

  • onig takes 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 bytes for 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!

image

@swanandx swanandx changed the title use onig crate for string API use onig crate for matching on strings Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant