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

Optimized string search / trim / slice methods #117

Open
overlookmotel opened this issue Sep 29, 2024 · 0 comments
Open

Optimized string search / trim / slice methods #117

overlookmotel opened this issue Sep 29, 2024 · 0 comments

Comments

@overlookmotel
Copy link

overlookmotel commented Sep 29, 2024

oxc-project/oxc#6151 introduced string search routines optimized for ASCII strings for parsing JSX pragmas.

These routines could be generalized and put in their own crate.

We use functions like str::trim all over the codebase, but it's quite slow as it handles non-ASCII characters in its hot path. But typical JS code which Oxc processes is almost entirely ASCII, so we can benefit from routines optimized for ASCII, which handle non-ASCII characters in a cold path.

trim_end introduced in oxc-project/oxc#6151 is a great deal smaller and faster on its hot ASCII path than std::str::trim_end: https://godbolt.org/z/4nfW6183z

We can also provide optimized string search routines where the character being searched for is ASCII (typical usage).

We may want to replicate Rust's nightly std::ascii::Char or reuse parts of the ascii crate.

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