mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Reduce allocations in attribute collection
This commit is contained in:
parent
c08df0f1f5
commit
cc04cfc982
9 changed files with 61 additions and 70 deletions
|
@ -160,14 +160,9 @@ impl ast::Attr {
|
|||
}
|
||||
|
||||
pub fn kind(&self) -> AttrKind {
|
||||
let first_token = self.syntax().first_token();
|
||||
let first_token_kind = first_token.as_ref().map(SyntaxToken::kind);
|
||||
let second_token_kind =
|
||||
first_token.and_then(|token| token.next_token()).as_ref().map(SyntaxToken::kind);
|
||||
|
||||
match (first_token_kind, second_token_kind) {
|
||||
(Some(T![#]), Some(T![!])) => AttrKind::Inner,
|
||||
_ => AttrKind::Outer,
|
||||
match self.excl_token() {
|
||||
Some(_) => AttrKind::Inner,
|
||||
None => AttrKind::Outer,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue