Skip to content

Commit 07de7a4

Browse files
Pre-intern name when searching module children
This avoids a good deal of work, since each module child can now just be compared via u32 comparison, rather than fetching the raw &str (requiring locking and indexing into the interner) and then comparing the two strings (also relatively expensive).
1 parent ccbfe50 commit 07de7a4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/tools/miri/src/helpers.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ fn try_resolve_did(tcx: TyCtxt<'_>, path: &[&str], namespace: Option<Namespace>)
3838
item: DefId,
3939
name: &'a str,
4040
) -> impl Iterator<Item = DefId> + 'a {
41+
let name = Symbol::intern(name);
4142
tcx.module_children(item)
4243
.iter()
43-
.filter(move |item| item.ident.name.as_str() == name)
44+
.filter(move |item| item.ident.name == name)
4445
.map(move |item| item.res.def_id())
4546
}
4647

0 commit comments

Comments
 (0)