mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-02 01:42:25 +00:00
Use CompactString
for Identifier
(#12101)
This commit is contained in:
parent
db6ee74cbe
commit
5109b50bb3
474 changed files with 4953 additions and 4776 deletions
|
@ -4,6 +4,7 @@ use std::ops::Deref;
|
|||
use bitflags::bitflags;
|
||||
use rustc_hash::{FxBuildHasher, FxHashSet};
|
||||
|
||||
use ruff_python_ast::name::Name;
|
||||
use ruff_python_ast::{
|
||||
self as ast, BoolOp, CmpOp, ConversionFlag, Expr, ExprContext, FStringElement, FStringElements,
|
||||
IpyEscapeKind, Number, Operator, UnaryOp,
|
||||
|
@ -477,14 +478,11 @@ impl<'src> Parser<'src> {
|
|||
let TokenValue::Name(name) = self.bump_value(TokenKind::Name) else {
|
||||
unreachable!();
|
||||
};
|
||||
return ast::Identifier {
|
||||
id: name.into_string(),
|
||||
range,
|
||||
};
|
||||
return ast::Identifier { id: name, range };
|
||||
}
|
||||
|
||||
if self.current_token_kind().is_soft_keyword() {
|
||||
let id = self.src_text(range).to_string();
|
||||
let id = Name::new(self.src_text(range));
|
||||
self.bump_soft_keyword_as_name();
|
||||
return ast::Identifier { id, range };
|
||||
}
|
||||
|
@ -499,7 +497,7 @@ impl<'src> Parser<'src> {
|
|||
range,
|
||||
);
|
||||
|
||||
let id = self.src_text(range).to_string();
|
||||
let id = Name::new(self.src_text(range));
|
||||
self.bump_any();
|
||||
ast::Identifier { id, range }
|
||||
} else {
|
||||
|
@ -509,7 +507,7 @@ impl<'src> Parser<'src> {
|
|||
);
|
||||
|
||||
ast::Identifier {
|
||||
id: String::new(),
|
||||
id: Name::empty(),
|
||||
range: self.missing_node_range(),
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +595,7 @@ impl<'src> Parser<'src> {
|
|||
);
|
||||
Expr::Name(ast::ExprName {
|
||||
range: self.missing_node_range(),
|
||||
id: String::new(),
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
})
|
||||
}
|
||||
|
@ -719,7 +717,7 @@ impl<'src> Parser<'src> {
|
|||
&parsed_expr,
|
||||
);
|
||||
ast::Identifier {
|
||||
id: String::new(),
|
||||
id: Name::empty(),
|
||||
range: parsed_expr.range(),
|
||||
}
|
||||
};
|
||||
|
@ -793,7 +791,7 @@ impl<'src> Parser<'src> {
|
|||
value: Box::new(value),
|
||||
slice: Box::new(Expr::Name(ast::ExprName {
|
||||
range: slice_range,
|
||||
id: String::new(),
|
||||
id: Name::empty(),
|
||||
ctx: ExprContext::Invalid,
|
||||
})),
|
||||
ctx: ExprContext::Load,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue