mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
Reduce size of Expr
from 80 to 64 bytes (#9900)
## Summary This PR reduces the size of `Expr` from 80 to 64 bytes, by reducing the sizes of... - `ExprCall` from 72 to 56 bytes, by using boxed slices for `Arguments`. - `ExprCompare` from 64 to 48 bytes, by using boxed slices for its various vectors. In testing, the parser gets a bit faster, and the linter benchmarks improve quite a bit.
This commit is contained in:
parent
bd8123c0d8
commit
49fe1b85f2
78 changed files with 326 additions and 258 deletions
|
@ -461,10 +461,10 @@ pub fn walk_expr<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, expr: &'a Expr) {
|
|||
range: _,
|
||||
}) => {
|
||||
visitor.visit_expr(left);
|
||||
for cmp_op in ops {
|
||||
for cmp_op in &**ops {
|
||||
visitor.visit_cmp_op(cmp_op);
|
||||
}
|
||||
for expr in comparators {
|
||||
for expr in &**comparators {
|
||||
visitor.visit_expr(expr);
|
||||
}
|
||||
}
|
||||
|
@ -594,10 +594,10 @@ pub fn walk_arguments<'a, V: Visitor<'a> + ?Sized>(visitor: &mut V, arguments: &
|
|||
// Note that the there might be keywords before the last arg, e.g. in
|
||||
// f(*args, a=2, *args2, **kwargs)`, but we follow Python in evaluating first `args` and then
|
||||
// `keywords`. See also [Arguments::arguments_source_order`].
|
||||
for arg in &arguments.args {
|
||||
for arg in arguments.args.iter() {
|
||||
visitor.visit_expr(arg);
|
||||
}
|
||||
for keyword in &arguments.keywords {
|
||||
for keyword in arguments.keywords.iter() {
|
||||
visitor.visit_keyword(keyword);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue