Skip to content

Commit

Permalink
ramfs: use drain instead of while loop + pop
Browse files Browse the repository at this point in the history
drain is shorter and faster :)

Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
  • Loading branch information
Freax13 committed Sep 12, 2024
1 parent 6048cd2 commit 5591c56
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/src/fs/ramfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ impl RawRamFile {
};

// Clear pages and remove them from the file
while self.pages.len() > new_pages {
let page_ref = self.pages.pop().unwrap();
for page_ref in self.pages.drain(new_pages..) {
page_ref.fill(0, 0);
}

Expand Down

0 comments on commit 5591c56

Please sign in to comment.