1
Fork 0

Auto merge of #78323 - est31:smaller_list_overlap, r=varkor

Iterate over the smaller list

If there are two lists of different sizes,
iterating over the smaller list and then
looking up in the larger list is cheaper
than vice versa, because lookups scale
sublinearly.
This commit is contained in:
bors 2020-10-28 03:58:32 +00:00
commit 2eb4fc800a
2 changed files with 32 additions and 7 deletions

View file

@ -266,6 +266,10 @@ impl<'tcx> AssociatedItems<'tcx> {
self.items.iter().map(|(_, v)| *v)
}
pub fn len(&self) -> usize {
self.items.len()
}
/// Returns an iterator over all associated items with the given name, ignoring hygiene.
pub fn filter_by_name_unhygienic(
&self,