Skip to content

Commit 9953b4c

Browse files
vax-rojeda
authored andcommitted
rust: list: Use "List::is_empty()" to perform checking when possible
"List::is_empty()" provides a straight forward convention to check whether a given "List" is empty or not. There're numerous places in the current implementation still use "self.first.is_null()" to perform the equivalent check, replace them with "List::is_empty()". Signed-off-by: I Hsin Cheng <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Rebased dropping the cases that do not apply anymore. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 249c3a0 commit 9953b4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<T: ?Sized + ListItem<ID>, const ID: u64> List<T, ID> {
319319

320320
/// Removes the last item from this list.
321321
pub fn pop_back(&mut self) -> Option<ListArc<T, ID>> {
322-
if self.first.is_null() {
322+
if self.is_empty() {
323323
return None;
324324
}
325325

@@ -331,7 +331,7 @@ impl<T: ?Sized + ListItem<ID>, const ID: u64> List<T, ID> {
331331

332332
/// Removes the first item from this list.
333333
pub fn pop_front(&mut self) -> Option<ListArc<T, ID>> {
334-
if self.first.is_null() {
334+
if self.is_empty() {
335335
return None;
336336
}
337337

0 commit comments

Comments
 (0)