ruff/crates/ruff_python_ast
Charlie Marsh ea1c089652
Use AhoCorasick to speed up quote match (#9773)
<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## 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:

```text
Parser/AhoCorasick      time:   [8.5646 ns 8.5914 ns 8.6191 ns]
Parser/Iterator         time:   [64.992 ns 65.124 ns 65.271 ns]
```

## Test Plan

`cargo test`
2024-02-02 09:57:39 -05:00
..
src Use AhoCorasick to speed up quote match (#9773) 2024-02-02 09:57:39 -05:00
tests Remove type parameter from parse_* methods (#9466) 2024-01-11 19:41:19 +01:00
Cargo.toml Use AhoCorasick to speed up quote match (#9773) 2024-02-02 09:57:39 -05:00