Skip to content

Commit 43ad4c0

Browse files
committed
specialize count for PageRange and PhysFrameRange
1 parent b0d8fc1 commit 43ad4c0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/structures/paging/frame.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ impl<S: PageSize> Iterator for PhysFrameRange<S> {
163163
None
164164
}
165165
}
166+
167+
#[inline]
168+
fn count(self) -> usize {
169+
if !self.is_empty() {
170+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
171+
} else {
172+
0
173+
}
174+
}
166175
}
167176

168177
impl<S: PageSize> fmt::Debug for PhysFrameRange<S> {

src/structures/paging/page.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ impl<S: PageSize> Iterator for PageRange<S> {
309309
None
310310
}
311311
}
312+
313+
#[inline]
314+
fn count(self) -> usize {
315+
if !self.is_empty() {
316+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
317+
} else {
318+
0
319+
}
320+
}
312321
}
313322

314323
impl PageRange<Size2MiB> {

0 commit comments

Comments
 (0)