Skip to content

Commit 76773a5

Browse files
committed
specialize count for PageRange and PhysFrameRange
1 parent 62c359f commit 76773a5

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
@@ -165,6 +165,15 @@ impl<S: PageSize> Iterator for PhysFrameRange<S> {
165165
None
166166
}
167167
}
168+
169+
#[inline]
170+
fn count(self) -> usize {
171+
if !self.is_empty() {
172+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
173+
} else {
174+
0
175+
}
176+
}
168177
}
169178

170179
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
@@ -305,6 +305,15 @@ impl<S: PageSize> Iterator for PageRange<S> {
305305
None
306306
}
307307
}
308+
309+
#[inline]
310+
fn count(self) -> usize {
311+
if !self.is_empty() {
312+
((self.end.start_address() - self.start.start_address()) / S::SIZE) as usize
313+
} else {
314+
0
315+
}
316+
}
308317
}
309318

310319
impl PageRange<Size2MiB> {

0 commit comments

Comments
 (0)