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:
parent
4d247ad7d3
commit
a21c2eb121
2 changed files with 12 additions and 0 deletions
|
@ -265,6 +265,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