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:
commit
2eb4fc800a
2 changed files with 32 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue