Skip to content

Refactor item attributes into a SortedIndexMultiMap<u32, Symbol, &Attribute> #94905

Closed
@cjgillot

Description

@cjgillot

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] by SortedIndexMultiMap<u32, Symbol, &ast::Attribute> in rustc_hir::hir, rustc_middle::query and rustc_middle::ty;
  • build the SortedIndexMultiMap in rustc_ast_lowering and rustc_metadata::decoder using Attribute::name_or_empty as key;
  • adapt the use sites to fetch the attributes using attrs.get_by_key(my_name) instead of attrs.iter().filter(|attr| attr.has_name(my_name);
  • evaluate performance impact.

Extra:

  • implement item_attrs query for the local crate, and replace calls to tcx.get_attrs by calls to tcx.item_attrs.

I am available on zulip for more detailed information.

Metadata

Metadata

Assignees

Labels

E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-help-wantedCall for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions