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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user