-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 AhoCorasick
to speed up quote match
#9773
Conversation
Some("\"") | ||
} else { | ||
None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a bit faster than the iterator approach though both are quite fast (1ns vs. 800ps).
I bet we could speed this up even more but this feels like good bang for buck: https://lemire.me/blog/2023/07/14/recognizing-string-prefixes-with-simd-instructions/ |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet.
.chain(SINGLE_QUOTE_STR_PREFIXES) | ||
.chain(SINGLE_QUOTE_BYTE_PREFIXES), | ||
) | ||
.unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. I'm glad you found StartKind::Anchored
.
Summary
When I was looking at the v0.2.0 release, this method showed up in a CodSpeed regression (we were calling it more), so I decided to quickly look at speeding it up. @BurntSushi suggested using Aho-Corasick, and it looks like it's about 7 or 8x faster:
Test Plan
cargo test