Use CompactString for Identifier (#12101)

This commit is contained in:
Micha Reiser 2024-07-01 10:06:02 +02:00 committed by GitHub
parent db6ee74cbe
commit 5109b50bb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
474 changed files with 4953 additions and 4776 deletions

View file

@ -1,7 +1,9 @@
use compact_str::CompactString;
use std::fmt::Display;
use rustc_hash::{FxBuildHasher, FxHashSet};
use ruff_python_ast::name::Name;
use ruff_python_ast::{
self as ast, ExceptHandler, Expr, ExprContext, IpyEscapeKind, Operator, Stmt, WithItem,
};
@ -623,7 +625,7 @@ impl<'src> Parser<'src> {
let range = self.node_range(start);
return ast::Alias {
name: ast::Identifier {
id: "*".into(),
id: Name::new_static("*"),
range,
},
asname: None,
@ -669,7 +671,7 @@ impl<'src> Parser<'src> {
fn parse_dotted_name(&mut self) -> ast::Identifier {
let start = self.node_start();
let mut dotted_name = self.parse_identifier().id;
let mut dotted_name: CompactString = self.parse_identifier().id.into();
let mut progress = ParserProgress::default();
while self.eat(TokenKind::Dot) {
@ -686,7 +688,7 @@ impl<'src> Parser<'src> {
// import a.b.c
// import a . b . c
ast::Identifier {
id: dotted_name,
id: Name::from(dotted_name),
range: self.node_range(start),
}
}