Skip to content

Commit 274d9f9

Browse files
bors[bot]Veykril
andauthored
Merge #10703
10703: internal: Don't check items for macro calls if they have no attributes r=Veykril a=Veykril Turns out when highlighting we currently populate the Dynmaps of pretty much every item in a file, who would've known that would be so costly... Shaves off 250 ms for the integrated benchmark on `rust-analyzer/src/config.rs`. We are still looking at a heft `154ms - descend_into_macros (2190 calls)` but I feel like this is slowly nearing towards just call overhead. bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents d1e449e + 8dad1b9 commit 274d9f9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/hir/src/semantics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
1717
use smallvec::{smallvec, SmallVec};
1818
use syntax::{
1919
algo::skip_trivia_token,
20-
ast::{self, HasGenericParams, HasLoopBody},
20+
ast::{self, HasAttrs, HasGenericParams, HasLoopBody},
2121
match_ast, AstNode, Direction, SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextSize,
2222
};
2323

@@ -588,7 +588,10 @@ impl<'db> SemanticsImpl<'db> {
588588
// are we inside an attribute macro call
589589
let containing_attribute_macro_call = self.with_ctx(|ctx| {
590590
token.value.ancestors().filter_map(ast::Item::cast).find_map(|item| {
591-
// investigate this, seems to be VERY(250ms) expensive in rust-analyzer/src/config.rs?
591+
if item.attrs().next().is_none() {
592+
// Don't force populate the dyn cache for items that don't have an attribute anyways
593+
return None;
594+
}
592595
Some((ctx.item_to_macro_call(token.with_value(item.clone()))?, item))
593596
})
594597
});

0 commit comments

Comments
 (0)