Skip to content

Commit 4fb47e4

Browse files
committed
specialize count for PageRange and PhysFrameRange
1 parent 73a051e commit 4fb47e4

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
@@ -161,6 +161,15 @@ impl<S: PageSize> Iterator for PhysFrameRange<S> {
161161
None
162162
}
163163
}
164+
165+
#[inline]
166+
fn count(self) -> usize {
167+
if !self.is_empty() {
168+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
169+
} else {
170+
0
171+
}
172+
}
164173
}
165174

166175
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
@@ -324,6 +324,15 @@ impl<S: PageSize> Iterator for PageRange<S> {
324324
None
325325
}
326326
}
327+
328+
#[inline]
329+
fn count(self) -> usize {
330+
if !self.is_empty() {
331+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
332+
} else {
333+
0
334+
}
335+
}
327336
}
328337

329338
impl PageRange<Size2MiB> {

0 commit comments

Comments
 (0)