mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 20:09:22 +00:00
Use separate structs for expression and statement tracking (#6351)
## Summary This PR fixes the performance degradation introduced in https://github.com/astral-sh/ruff/pull/6345. Instead of using the generic `Nodes` structs, we now use separate `Statement` and `Expression` structs. Importantly, we can avoid tracking a bunch of state for expressions that we need for parents: we don't need to track reference-to-ID pointers (we just have no use-case for this -- I'd actually like to remove this from statements too, but we need it for branch detection right now), we don't need to track depth, etc. In my testing, this entirely removes the regression on all-rules, and gets us down to 2ms slower on the default rules (as a crude hyperfine benchmark, so this is within margin of error IMO). No behavioral changes.
This commit is contained in:
parent
61d3977f95
commit
b21abe0a57
11 changed files with 223 additions and 157 deletions
|
@ -2,19 +2,21 @@ pub mod analyze;
|
|||
mod binding;
|
||||
mod context;
|
||||
mod definition;
|
||||
mod expressions;
|
||||
mod globals;
|
||||
mod model;
|
||||
mod node;
|
||||
mod reference;
|
||||
mod scope;
|
||||
mod star_import;
|
||||
mod statements;
|
||||
|
||||
pub use binding::*;
|
||||
pub use context::*;
|
||||
pub use definition::*;
|
||||
pub use expressions::*;
|
||||
pub use globals::*;
|
||||
pub use model::*;
|
||||
pub use node::*;
|
||||
pub use reference::*;
|
||||
pub use scope::*;
|
||||
pub use star_import::*;
|
||||
pub use statements::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue