Closed
Description
Now, when code needs to look up attributes on an item, it fetches the complete list of attributes and sequentially looks for the interesting one. This could be made more efficient by making the attribute list a SortedIndexMultiMap
.
Steps:
- replace
&[ast::Attribute]
bySortedIndexMultiMap<u32, Symbol, &ast::Attribute>
inrustc_hir::hir
,rustc_middle::query
andrustc_middle::ty
; - build the
SortedIndexMultiMap
inrustc_ast_lowering
andrustc_metadata::decoder
usingAttribute::name_or_empty
as key; - adapt the use sites to fetch the attributes using
attrs.get_by_key(my_name)
instead ofattrs.iter().filter(|attr| attr.has_name(my_name)
; - evaluate performance impact.
Extra:
- implement
item_attrs
query for the local crate, and replace calls totcx.get_attrs
by calls totcx.item_attrs
.
I am available on zulip for more detailed information.