Skip to content

Commit fa60072

Browse files
authored
refactor: use FdtNode::child in Fdt::find_node (#13)
This simplifies the implementation by reducing duplicate code.
1 parent 87b2daa commit fa60072

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

src/fdt/mod.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -425,18 +425,8 @@ impl<'a> Fdt<'a> {
425425
return Ok(Some(current_node));
426426
}
427427
for component in path.split('/').filter(|s| !s.is_empty()) {
428-
let include_address = component.contains('@');
429-
match current_node.children().find(|child| {
430-
child.as_ref().is_ok_and(|c| {
431-
if include_address {
432-
c.name().is_ok_and(|n| n == component)
433-
} else {
434-
c.name_without_address().is_ok_and(|n| n == component)
435-
}
436-
})
437-
}) {
438-
Some(Ok(node)) => current_node = node,
439-
Some(Err(e)) => return Err(e),
428+
match current_node.child(component)? {
429+
Some(node) => current_node = node,
440430
None => return Ok(None),
441431
}
442432
}

0 commit comments

Comments
 (0)