Skip to content

Commit 78a27d1

Browse files
committed
Remove unsafe indexing.
The compiler probably optimizes the checks away anyway.
1 parent 98f86a4 commit 78a27d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/structures/paging/page_table.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,16 @@ impl IndexMut<usize> for PageTable {
217217
impl Index<PageTableIndex> for PageTable {
218218
type Output = PageTableEntry;
219219

220+
#[inline]
220221
fn index(&self, index: PageTableIndex) -> &Self::Output {
221-
// Safety: A PageTableIndex never contains a value >= 512.
222-
unsafe { self.entries.get_unchecked(usize::from(index)) }
222+
&self.entries[usize::from(index)]
223223
}
224224
}
225225

226226
impl IndexMut<PageTableIndex> for PageTable {
227+
#[inline]
227228
fn index_mut(&mut self, index: PageTableIndex) -> &mut Self::Output {
228-
// Safety: A PageTableIndex never contains a value >= 512.
229-
unsafe { self.entries.get_unchecked_mut(usize::from(index)) }
229+
&mut self.entries[usize::from(index)]
230230
}
231231
}
232232

0 commit comments

Comments
 (0)