pci: Accept MmioRegion reference in has_matching_slots()
Change has_matching_slots() to compare two MmioRegion instances directly rather than requiring callers to construct an intermediate HashSet of slot numbers. Remove the now-unused user_memory_region_slots() method and HashSet import. Signed-off-by: Damian Barabonkov <dbctl@pm.me>
This commit is contained in:
parent
c2add07476
commit
638848fcff
1 changed files with 11 additions and 0 deletions
|
|
@ -276,6 +276,17 @@ pub struct MmioRegion {
|
||||||
pub(crate) user_memory_regions: Vec<UserMemoryRegion>,
|
pub(crate) user_memory_regions: Vec<UserMemoryRegion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MmioRegion {
|
||||||
|
/// Returns true if this region has the exact same memory slots as the other region.
|
||||||
|
pub fn has_matching_slots(&self, other: &MmioRegion) -> bool {
|
||||||
|
self.user_memory_regions.len() == other.user_memory_regions.len()
|
||||||
|
&& self
|
||||||
|
.user_memory_regions
|
||||||
|
.iter()
|
||||||
|
.all(|u| other.user_memory_regions.iter().any(|o| o.slot == u.slot))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// [`Self::find_user_address`] must always either return `Err`
|
/// [`Self::find_user_address`] must always either return `Err`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue