Skip to content

Commit 91da0b2

Browse files
committed
specialize count for PageRange and PhysFrameRange
1 parent ef5a96c commit 91da0b2

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
@@ -296,6 +296,15 @@ impl<S: PageSize> Iterator for PageRange<S> {
296296
None
297297
}
298298
}
299+
300+
#[inline]
301+
fn count(self) -> usize {
302+
if !self.is_empty() {
303+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
304+
} else {
305+
0
306+
}
307+
}
299308
}
300309

301310
impl PageRange<Size2MiB> {

0 commit comments

Comments
 (0)