mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +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
|
@ -38,7 +38,7 @@ impl FormatNodeRule<Arguments> for FormatArguments {
|
|||
let all_arguments = format_with(|f: &mut PyFormatter| {
|
||||
let source = f.context().source();
|
||||
let mut joiner = f.join_comma_separated(range.end());
|
||||
match args.as_slice() {
|
||||
match args.as_ref() {
|
||||
[arg] if keywords.is_empty() => {
|
||||
match arg {
|
||||
Expr::GeneratorExp(generator_exp) => joiner.entry(
|
||||
|
@ -180,7 +180,7 @@ fn is_single_argument_parenthesized(argument: &Expr, call_end: TextSize, source:
|
|||
/// of those collections.
|
||||
fn is_arguments_huggable(arguments: &Arguments, context: &PyFormatContext) -> bool {
|
||||
// Find the lone argument or `**kwargs` keyword.
|
||||
let arg = match (arguments.args.as_slice(), arguments.keywords.as_slice()) {
|
||||
let arg = match (arguments.args.as_ref(), arguments.keywords.as_ref()) {
|
||||
([arg], []) => arg,
|
||||
([], [keyword]) if keyword.arg.is_none() && !context.comments().has(keyword) => {
|
||||
&keyword.value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue